Search code examples
iphoneipaduniversaluifont

How to make the font scale


I am making an universal application for iPhone and iPad. I know there is a option to define that the text should scale downwards to a chosen point-size when it is to large however I need the text to scale upwards when the text is shown on the iPad. Is that possible? I have a label with a size of 18 points. This almost occupy the whole width on the iPhone with the length of the text in consideration. But on iPad this will not be the case because of the increased size of the screen...

Thank you for your time.


Solution

  • You could loop on the method:

    - (CGSize)sizeWithFont:(UIFont *)font constrainedToSize:(CGSize)size lineBreakMode:(UILineBreakMode)lineBreakMode
    

    until you get a match that takes up two lines, then use the previous font-size. Seems quicker/easier to just use idioms to define a specific size for the iPad.