To change the appearance of text in all UIBarButtonItems displayed in all UIBarButtonItems UINavigationBars , follow these steps in the application:didFinishLaunchingWithOptions:
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes: @{UITextAttributeTextColor:[UIColor blackColor], UITextAttributeTextShadowOffset:[NSValue valueWithUIOffset:UIOffsetMake(0, 1)], UITextAttributeTextShadowColor:[UIColor whiteColor], UITextAttributeFont:[UIFont boldSystemFontOfSize:12.0] } forState:UIControlStateNormal];
UPDATE: iOS7 friendly version
NSShadow *shadow = [[NSShadow alloc] init]; shadow.shadowOffset = CGSizeMake(0.0, 1.0); shadow.shadowColor = [UIColor whiteColor]; [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes: @{NSForegroundColorAttributeName:[UIColor blackColor], NSShadowAttributeName:shadow, NSFontAttributeName:[UIFont boldSystemFontOfSize:12.0] } forState:UIControlStateNormal];
Swift:
NOTE: this changes ALL instances of the UIBarButtonItem , not just those contained in the UINavigationBar
UIBarButtonItem.appearance() .setTitleTextAttributes([NSFontAttributeName : ExamplesDefaults.fontWithSize(22)], forState: UIControlState.Normal)
Swift3:
UIBarButtonItem.appearance() .setTitleTextAttributes([NSFontAttributeName: UIFont(name: "FontName-Regular", size: 14.0)!], for: .normal)
Mike Pollard May 14 '13 at 8:40 2013-05-14 08:40
source share