Search code examples
cocoa-touchuilabeladjustment

Do not autoresize UILabel


everybody, this is my question:

i have a UILabel that displays the hour with seconds in the format HH:mm:ss. But, the content of the label always move to the right when the seconds are: '01' because the number 1 is "smaller" than the width of the number 9.

i had unchecked "Adjust to fit" in IB and setAdjustsFontSizeToWidth:NO but that did not solve the problem.

I think the answer is there in IB but anything seems to work.

Any idea ??


Solution

  • You can use this which is inherited from UIView:

    @property(nonatomic) BOOL autoresizesSubviews
    

    and set it to false, if you just don't want the UILabel to autoresize.