Search code examples
iosobjective-cios7

iOS 7 - Change bar button size


Is there any legitimate way to change the size of a bar button in iOS 7 (i.e. the font size of the text)? I find the default bar button size a bit too big comparing to the navigation bar title.


Solution

  • Use the setTitleTextAttributes:forState: method on the UIBarButtonItem.

    NSDictionary *attrs = @{ NSFontAttributeName : [UIFont systemFontOfSize:10] };
    [barButtonItem setTitleTextAttributes:attrs forState:UIControlStateNormal];
    

    Obviously you can choose whatever font you want.