How to center a label horizontally for all iOS devices in Swift
16,443
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.
Comments
-
Katz almost 2 years
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 theWhat 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
-
Katz over 8 yearsDo I select the label and the stack view when doing the constrains? because if I don't the buttons don't appear. Since I have to select both stack view and label does the constrain change?
-
Mehul Sojitra over 8 yearsYour stack view contains three images(emojis) which is shown in screen shot correct??
-
Mehul Sojitra over 8 yearsYou say that "if I don't the buttons don't appear" which button you say?(is this after the label? in screen shot).
-
Katz over 8 yearsWhat I did was Select Stack view and label and added 43 as you answered and I did work like I wanted it work, but I have a lot of
Issues
on the side. for example it says "Frame for Stack View will be different at run time" -
Katz over 8 yearsI updated the question with issues shown on the side.
-
Mehul Sojitra over 8 yearsHi, sorry but Don't consider value from my screen shot as 43 is top space from super view and in your case may be is 29 as you posted in your screen shot. I capture that screen shot only for displaying you which constraints are required please ignore the value of top, width and height contains.
-
Mehul Sojitra over 8 yearsLet us continue this discussion in chat.