How to center the label horizontally for all iOS devices in Swift

I can't figure out how to make the label horizontally center in the image view. The label says "You've been here. What would you rate us , I want What would you rate us be under "You've been here." I tried to do this to add 2 labels to the labels and select the plus label 3 buttons and click β€œAdd missing restrictions.” When I run the program, this is the result.

How can I fix this so that text is entered on all devices?

enter image description here

Limitations

enter image description here

+5
source share
4 answers

try adding constraints for your label, for example:

Add restrictions on top, width and height, as shown in the figure below, and make sure that the restrictions on the fields are removed.

enter image description here

And set horizontal limits in the center.

enter image description here

+6
source

click label

 1.Don't set any heights 2.Now set top space to the container view 3.centre horizontal to container view 4.now set the height (or) bottom space to the smiley Add this all constraints you will get what you expected :) 
0
source

enter image description here

  • Add vertical top spacing for a specific image
  • Add horizontal center in the same image
  • Then adjust the lead and end as well as the drag and drop. it is just easy.
0
source

just use this code:

 yourLabel.translatesAutoresizingMaskIntoConstraints = YES; CGPoint centerPoint = yourLabel.center; centerPoint.x = yourImageView.center.x; yourLabel.center = centerPoint; 
0
source

Source: https://habr.com/ru/post/1239111/


All Articles