0

I am using this code:

CGSize currentItemSize = [@"A" sizeWithFont:[UIFont fontWithName:@"HelveticaNeue" size:13.0] constrainedToSize:CGSizeMake(30.0, 20.0) lineBreakMode:NSLineBreakByClipping];

and I get height 17.0 when in fact on screen this letter is smaller.

I have tried also sizeWithFont: without constrained and lineBreak mode but the result is always the same.

I would like the method which could provide me with the height of the tallest letter in a given NSString (for example @"zy" letter "y" is taller than "z". Does anyone know how to do it?

4

1 回答 1

1

你得问UIFont

UIFont *font = [UIFont fontWithName:@"HelveticaNeue" size:13.0];

NSLog(@"Capital Letter Height: %f", font.capHeight);
NSLog(@"X Height: %f", font.xHeight);
NSLog(@"Lower Letter Height: %f", font.xHeight - font.descender);
于 2013-06-27T19:20:39.097 回答