vishal dharankar
vishal dharankar

Reputation: 7746

Autolayout UILabel inside a UIView

I have a UIView and inside that there is a subview which is UIView again, inside that UIView i want to add a UILabel at the centre , I am using Autolayout. I have added all the constraints to all the views , but UILabel at the centre is only visible on iPad screens, it goes missing on smaller screen, my doubt is, when its coordinates, when are calculated on resized parent UIView, turns out to be wrong or it gets squeezed so much that it becomes invisible.

Please help me on this, I am not an expert in auto layout so obvious. Thanks

enter image description here

enter image description here

Also the outer UIView will be presented fullscreen in parent ViewController

Upvotes: 0

Views: 943

Answers (3)

Ketan Parmar
Ketan Parmar

Reputation: 27428

set leading,trailing,horizontal center in container and top constrain to label with it's container view.

Upvotes: 1

Rajan Maheshwari
Rajan Maheshwari

Reputation: 14571

These are my constraints

enter image description here

And this is my Layout in all screens

enter image description here

Where your label is centered and also the Black View is increasing height with aspect ratio as per the device's height

Upvotes: 1

fahad khan
fahad khan

Reputation: 89

You should align it horizontally in the container.and also no one will be able to help unless you show all the constraints.

Upvotes: 0

Related Questions