Search code examples
iphoneioscocoa-touchuilabelautoresize

iOS: How to tell if UILabel's font has been auto-resized?


Is there a way to programmatically determine whether the text within a label has been auto-resized?


Solution

  • You could probably check the size of the text with the font and compare it to the label's width.

    Maybe something like this:

    CGSize size = [yourLabel.text sizeWithFont:label.font constrainedToSize:CGSizeMake(100000, yourLabel.frame.size.height)  lineBreakMode:yourLabel.lineBreakMode];
    
    if(size.width > label.frame.size.width)
    {
        //you are being autosized
    }