Nitish
Nitish

Reputation: 14113

Change text color of default back button in storyboard

How to change text color of default back button in storyboard.(Both through storyboard and programmatically)? The default color which appears is blue. This question helps in setting text for back button but not the color.

Navigation Bar Image

Upvotes: 8

Views: 6990

Answers (7)

Lucca Mordente
Lucca Mordente

Reputation: 1131

In Xcode 11 you can simply set the tint property for the Navigation Bar object inside the attributes inspector.

See screenshot below:

enter image description here

It took some time for the changes to take place on the preview for me, but you can see the changes when you run your app.

Upvotes: 0

Mark Dail
Mark Dail

Reputation: 500

To change the color of the back button for the whole app in Storyboard, select the Navigation Bar in the Navigation Controller. Select the Show the File Inspector in the Utilities Pane. At the bottom of the Interface Builder Document section, set the Global Tint. This will set the color of the back button as well as the Title text of the Navigation Bar for all the View Controller in your app to the color you select.

Upvotes: 0

Krešimir Prcela
Krešimir Prcela

Reputation: 4281

The color of the back button will be set from storyboard global tint color.

enter image description here

Upvotes: 9

LaurelS
LaurelS

Reputation: 492

Using Storyboards - no code changes - I had somehow reset my BACK button to yellow (and boy has that been irritating!) I clicked on the 'Tab Bar Controller' within the 'Tab Bar Controller Scene' and then changed the 'Global Tint' in the 'File Inspector' Hooray! You can actually read the BACK button now.

Changing BACK button Color

Upvotes: 1

Sujith Chandran
Sujith Chandran

Reputation: 2721

through StoryBoard you can easily set the tint colour.

Select the Navigation Bar tab of your Navigation Controller and then in attributes inspector you can select the tint colour.

Upvotes: 3

Nitish
Nitish

Reputation: 14113

This is my fix :

[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName: [UIColor whiteColor]}];
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];  

It works for iOS 7+.

Upvotes: 0

soulshined
soulshined

Reputation: 10602

Nitish,

In your storyboard sidebar make sure you select the Navigation Bar tab of your Navigation Controller - not your table view. Then change the background color of your navigation bar to whatever you have set. Some blue color. As far as I know you can't change the color of your back button within storyboard so after you set the Navigation bar controller color in storyboard like the picture:

Storyboard Then you can accomplish this by putting the following code in your viewDidLoad method:

self.navigationController.navigationBar.tintColor = [UIColor whiteColor]; //your color of what you want, I assume you want white based on your background color

And the outcome will be like so:

Final Outcome

Upvotes: 8

Related Questions