I’m using -[NSString sizeWithFont] to get the text height. The character ‘t’ is clearly taller than ‘m’, but -sizeWithFont returns the same height for both these strings. Here’s the code:
UIFont* myFont = [UIFont fontWithName:@"Helvetica" size:1000.0];
NSString* myStr = @"m";
CGSize mySize = [myStr sizeWithFont:myFont];
With ‘m’ as shown, it returns {834, 1151}. With myStr = @"t" instead, it’s {278, 1151}. The smaller width shows up as expected, but not the height.
Does some other function wrap the text tightly? I’m ideally looking for something equivalent to Android’s Paint.getTextBounds().
Hmmm… I assume you’re only going to be working with individual characters then.
sizeWithFont, as noted above, returns the height of the largest character of that font as the text field is going to be that height no matter what you do. You would be able to get the LARGEST height values (UIFont’sCGFloat capHeight) however it looks like you’re going to be working with all kinds of textI would take a look at the CoreText framework. Start here and read away. Inevitably you’re going to end up with something along the lines of this: