code-8
code-8

Reputation: 58672

Place label on top of each other next to an image

I'm trying to place a label on top of label next to my image.

enter image description here

I have tried

enter image description here

I had

enter image description here

I want these number to display here

enter image description here

Should I look into a stack or some short?

Upvotes: 0

Views: 262

Answers (2)

MadProgrammer
MadProgrammer

Reputation: 347244

In this case, I might be tempted to just use a UIStackView - it might be a little overkill, but one of the benefits is if you hide one of the labels (because it's text is nil) it will reduce the size of the StackView, which, personally, makes the layout look nicer, but that's me

General layout...

General layout

UIImageView constraints

UIImageView constraints

UIStackView constraints

StackView constraints

UIStackView properties

UIStackView properties

*nb: This still assumes that the overall height of the text won't exceed the height of the UIImageView

Upvotes: 2

Shivam Tripathi
Shivam Tripathi

Reputation: 1493

Based on your requirement, I created it in storyboard; u can do same like it to achieve your prototype :

  • Constraints for label 2 (Devices):

enter image description here

  • Constraints for Label 1 (John) :

enter image description here

I hope it clears your doubt.

Upvotes: 1

Related Questions