Setting the titleLabel.font property of a of a UIButton not working

gossainapps picture gossainapps · Oct 13, 2013 · Viewed 18k times · Source

In currently working with iOS 7 and I an attempting to increase the font size of the titleLabel of my UIButton. I am doing it like this,

[[_centerButton titleLabel] setFont:[UIFont boldSystemFontOfSize:28.0]];

However this does not do anything. Every time I compile with a different size the font always stays the same. Even when I completely delete that line the font stays the same. Apparently it is sticking to the default size.

How can I increase the font size of my UIButton title?

Answer

Niklas picture Niklas · Oct 13, 2013

Have a look at the official UIButton class reference on https://developer.apple.com/library/ios/documentation/uikit/reference/UIButton_Class/UIButton/UIButton.html#//apple_ref/occ/instp/UIButton/titleLabel

It says that you're actually able to set the font with your method:

button.titleLabel.font = [UIFont systemFontOfSize: 12];