Giulio Colleluori
Giulio Colleluori

Reputation: 1361

AutoLayout Dynamic Width UILabel

I'm trying to make a UILabel with dynamic width with AutoLayout. Meaning on any screen size, is going to have a fixed height and a width that goes from 10 px from its superview left margin and 10 from the right. I also have another constraint 10 from the top. When I set those constraints and I update the frame however, this is what I get :

enter image description here

While this is how it's supposed to be :

How the UILabel should look

If you could please let me know what do you think could be the issue here that would be really appreciated.

Thank you in advance.

Upvotes: 0

Views: 694

Answers (1)

Ghulam Ali
Ghulam Ali

Reputation: 1935

I tested the following constraints will create left margin of 10 from left and 10 from right.

Constraints Preview

When you had made these constraints goto Editor -> Resolve Auto Layout Issues -> All Views in View -> Update Frames

Interface Builder Preview

Upvotes: 1

Related Questions