I set the UILabels frame based on what UIFont sizeWithFont returns, but for some reason, when I use my own font, the return values ββinclude some additions, as shown below.
When I use boldSystemFontOfSize , the text is vertically aligned in the middle (this is what I want), but when I use fontWithName , I end up filling under the text, Any reason why sizeWithFont is added in addition?

Here is my code ...
CGRect frameLabel = label.frame; CGSize sizeLabel = [label.text sizeWithFont:label.font]; frameLabel.size.width = sizeLabel.width; frameLabel.size.height = sizeLabel.height; [label setBackgroundColor:[UIColor redColor]];
** Change **
I can calculate the top and bottom padding with this code and adjust the labels of frame.origin.y to vertically center my label where it should be
float topPadding = [label.font ascender] - [label.font capHeight]; float bottomPadding = [label.font lineHeight] - [label.font ascender];
source share