Bijoy Thangaraj
Bijoy Thangaraj

Reputation: 5546

Change the default font of Back button in UINavigationController

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.

enter image description here

Upvotes: 3

Views: 3893

Answers (1)

nitin kachhadiya
nitin kachhadiya

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

Related Questions