Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

iOS 7: What is UIBarButtonItem's default font?

What is the default font of the title of a UIBarButtonItem with a style of UIBarButtonItemStyleDone?

The following just returns nil:

[doneBarButtonItem titleTextAttributesForState:UIControlStateNormal]

like image 286
ma11hew28 Avatar asked Sep 22 '13 16:09

ma11hew28


2 Answers

[UIFont boldSystemFontOfSize:17]

Note: I confirmed this by doing:

UIFont *font = [UIFont boldSystemFontOfSize:17];
[doneBarButtonItem setTitleTextAttributes:@{NSFontAttributeName: font}
                                 forState:UIControlStateNormal];

And then, I took screenshots of the before & after and compared them. They were identical.

like image 111
ma11hew28 Avatar answered Sep 21 '22 09:09

ma11hew28


You can retrieve the default font for a UILabel (which includes UIBarButton's title label) by querying

UIFont.systemFont(ofSize: UIFont.labelFontSize)
like image 34
Felix Avatar answered Sep 20 '22 09:09

Felix