Thursday, 3 October 2013

UILabel with multiple lines and Auto Resizing Masks (UIViewAutoresizingMask)

UILabel with multiple lines and Auto Resizing Masks (UIViewAutoresizingMask)

I have a problem with UILabels that contain text that is spread on
multiple lines. It's nested into a fullscreen UIView that has autoresizing
mask as well:
view.autoresizingMask =
UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
I'd like to add autoresizingMask on the label
label.autoresizingMask =
UIViewAutoresizingFlexibleHeight|UIViewAutoresizingFlexibleWidth;
But the problem is, this doesn't work as I'd like it to work. If I do
this, after rotating the screen (which changes size of the view) then the
label has smaller height and some of the text is cut off. (It doesn't
display the whole text). If I don't add UIViewAutoresizingFlexibleHeight,
then the label after rotation has big gaps above and under text (And I
don't want that). I tried adding also
UIViewAutoresizingFlexibleBottomMargin, but this doesn't help, as still
not whole text is displayed. I really don't know how to make this work,
I'm almost convinced autoresizing masks don't work with multiline
uilabels... Any idea on this would be appreciated. Thanks :)

No comments:

Post a Comment