Search code examples
iosswiftautolayoutnslayoutconstraint

Putting UIImage in between UILabels text


Currently I use this constraints to show user's notifications.

User Name.leading = User Image.trailing + 5
Status Image.leading = User Name.trailing + 2
Status Image.centerY = User Name.centerY
Notification Message.leading = Status Image.trailing + 3
Notification Message.trailing ≤ Notification Post.leading - 3
trailing = Notification Post.trailing + 5

And it gives me this result : enter image description here

But i want the Notification Message to align left when line count is bigger than 1. How can i achieve it ? Is it possible when I use 2 different UILabels for UserName and NotificationMessage ? The actual UI positions I need to do is here: enter image description here

How can i achieve this? I would be grateful for any idea.


Solution

  • Use one label to achieve this.