brush51
brush51

Reputation: 5771

How to autosize label like this InterfaceBuilder Settings?

i want to set the autosize settings for an uilabel programmatically.
i want exactly the same settings like in the interface builder settings i set, see here:

http://imageshack.us/photo/my-images/545/bildschirmfoto20120508u.png/

so how can i set it programmatically? i want full width.

i have tried it with:

titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth;  

But when i use this, my label is very strange (in portraitmode is the width 0 and in landscape approx 100).

so how to do?

Upvotes: 2

Views: 5783

Answers (1)

Lefteris
Lefteris

Reputation: 14677

From what I see you want full width, but flexible bottom, so you should use this autoresizing mask value:

titleLabel.autoresizingMask = UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleRightMargin | UIViewAutoresizingFlexibleLeftMargin | UIViewAutoresizingFlexibleTopMargin; 

Upvotes: 5

Related Questions