Jackster
Jackster

Reputation: 41

How to align UILabel text to the vertical centre of box

After using Auto shrink the text aligns itself to the top of the text box

 ____________
| AutoSized  |
|            |
|            |
 ____________

I need the text to align to the very centre like this

 ____________
|            |
| AutoSized  |
|            |
 ____________

How do I do this?

Lines is set to 0 otherwise the AutoShrink doesn't work well and cuts off the text. Baseline is set to align centres but the options don't change anything.

Upvotes: 0

Views: 467

Answers (1)

Matthew Seaman
Matthew Seaman

Reputation: 8092

In Interface Builder, set constraints by control-dragging from the label to the view behind it at an oblique angle and align it to both horizontal and vertical centers:

Control-drag for constraint

Center on each axis

Upvotes: 1

Related Questions