UIButton custom font vertical alignment

Posted by Willshaw Media on Stack Overflow See other posts from Stack Overflow or by Willshaw Media
Published on 2011-09-23T22:34:19Z Indexed on 2013/10/24 9:55 UTC
Read the original article Hit count: 249

I've got a UIButton which uses a custom font, which is set when my view loads:

- (void)viewDidLoad
{
    [super viewDidLoad];    
    self.searchButton.titleLabel.font = [UIFont fontWithName: @"FONTNAME" size: 15.0 ];
}

The problem I've got is that the font is appearing to float up of the center line. If I comment out this line, the default font appears vertically centered fine. But changing to the custom font breaks the vertical alignment.

I'm getting the same issue on a Table Cell with a custom font too.

Do I need to tell the view somewhere that the custom font is not as tall as other fonts?

EDIT: I've just realized that the font I'm using is a Windows TrueType Font. I can use it fine in TextEdit on the Mac, only a problem with the alignment in my App

Button text not vertically centered

© Stack Overflow or respective owner

Related posts about ios

Related posts about objective-c