Question

I'm using some custom fonts I added to my project for the titles of UIButton. I am not able to set my custom fonts in IB, and I've read in some posts that it is not possible yet in the last XCode version, is that right? So, currently, I'm setting the font for the titles programmatically. The point is that, as in IB the font is set to the default, when I set my custom font programmatically it is not centered, I guess because the font I can see in IB for the button has another height and width and this is the size considered to center the title. How could I center the title with my custom font?

Thanks!

Was it helpful?

Solution 2

The problem came from the custom font, that it introduced some space below characters. This post solved my problem:

UIButton custom font vertical alignment

OTHER TIPS

Try this.

[button setContentHorizontalAlignment:UIControlContentHorizontalAlignmentCenter];

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top