Vertically align text in UIlabel

I want the text written in the UILabel to be vertically centered.

How can i do this? My shortcut name is phoneLabel. Here I am attaching an image:

See phone number, the label is fully aligned with the whatsapp image, but the text doesn't look very good as it is not vertically aligned.

Below are the contraindications:

+3


source to share


1 answer


The problem is that you added top space = 6 for the UILabel to remove it. Add a center vertical constraint to the image.

Also, if you have set leading and trailing then there is no need for width restrictions.



Make sure below things

  • Set limits on the phoneLabel, which is vertically centered on the whatsapp image.
  • Set content / text alignment in UILabel as Center.
  • Remove top and bottom distance UILabel . Only these constraints are sufficient height, central vertical to the image, leading and trailing spaces.
0


source







All Articles