1

I have a UILabel with a defined frame. The size of the frame is determined by auto layout properties. When the text of the label is to small I get it is located in the middle of the frame. Here is an example:

-------------------
-                 -
-  A short Text   -
-                 -
-------------------

I want that the text starts at the top of the label's frame like this:

-------------------
-A short Text     -
-                 -
-                 -
-------------------

Not that the box I painted I the frame of the UILabel.

How can I achieve that the label is positioned at the top vertically as shown in the second image?

Sven Bauer
  • 1,619
  • 2
  • 13
  • 22
  • 1
    possible duplicate of [Vertically align text within a UILabel](http://stackoverflow.com/questions/1054558/vertically-align-text-within-a-uilabel) – Sujay Jun 26 '15 at 13:25
  • Put the label into a containing view. Add left,right,top,bottom constraints to center the label, but make the left and top that have lower priority than the other two. Add a hard constraint to the label so its width cannot be less than some minimum. Now as the containing view gets shrunk the label inside will ultimately end up top left. Should work. – David H Jun 26 '15 at 14:20

0 Answers0