Reputation: 866
I can't figure out how to make the label horizontally center in a image view, The label says "You've been here. What would you rate us
, I want the What would you rate us
to be under the "You've been here."
What I attempted to do accomplish this was to add 2 lines to the labels and select the label plus the 3 buttons and clicked on "Add Missing Constrains". When I run the program this is the result.
How can I fix it so the text is entered on all devices?
Constrains
Upvotes: 10
Views: 17569
Reputation: 4375
Click the label
Don't set any heights
Now set top space to the container view
Centre horizontal to container view
Now set the height (or) bottom space to the smiley
Add this all constraints you will get what you expected.
Upvotes: 0
Reputation: 1181
for your label try to add constraints like:
Add top, width and height constraints as shown in below screen shot and make sure that constraints to margins is uncheck.
And set horizontal center constraints.
Upvotes: 22
Reputation: 953
just use this code :
yourLabel.translatesAutoresizingMaskIntoConstraints = YES;
CGPoint centerPoint = yourLabel.center;
centerPoint.x = yourImageView.center.x;
yourLabel.center = centerPoint;
Upvotes: 0
Reputation: 618
Upvotes: 0