Reputation: 5546
I am trying to change the default font of Back button in UINavigationController to a custom font
UIFont *myCustomFont = [UIFont fontWithName:@"MyCustomFont" size:18];
How can I set this custom font to the Back Button? I've browsed through other answers to similar questions in this site with no success.
Upvotes: 3
Views: 3893
Reputation: 969
[[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:
@{UITextAttributeTextColor:[UIColor blackColor],
UITextAttributeTextShadowOffset:[NSValue valueWithUIOffset:UIOffsetMake(0, 1)],
UITextAttributeTextShadowColor:[UIColor whiteColor],
UITextAttributeFont: myCustomFont
}
forState:UIControlStateNormal];
Upvotes: 3