Jesús Ayala
Jesús Ayala

Reputation: 2791

how to change backbutton color iOS7

I've been developed an app for iOS7 which has this design

enter image description here

As you can see there's a blue arrow for all my BackButton (using UINavigationController and segues), I want to make them red, this is my code:

[UIBarButtonItem   appearance]setTintColor:(UIColorFromRGB(toolbarTintColor))];
[[UIBarButtonItem  appearance]setTitleTextAttributes:textAtributesDictionaryNavBarButtons forState:UIControlStateNormal];

but results only applies to all other buttons, any help I'll appreciate

thanks in advance for the support

Upvotes: 19

Views: 15316

Answers (8)

fujianjin6471
fujianjin6471

Reputation: 5248

You can set it in IB directly:

enter image description here

Upvotes: 1

osvin websolutns
osvin websolutns

Reputation: 1

-(void)viewDidAppear:(BOOL)animated
{
   //set back button color
    [[UIBarButtonItem appearanceWhenContainedIn:[UINavigationBar class], nil] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor redColor], NSForegroundColorAttributeName,nil] forState:UIControlStateNormal];
    //set back button arrow color
    [self.navigationController.navigationBar setTintColor:[UIColor whiteColor]];
}

Upvotes: -2

yunhasnawa
yunhasnawa

Reputation: 965

Put this code in your App Delegate:

Objective-C

[self.window setTintColor:[UIColor redColor]];

Swift

self.window?.tintColor = UIColor.redColor()

Upvotes: 12

raja
raja

Reputation: 1161

  • If you're using storyboard, then you've to add a user defined attribute for keyPath 'tintColor' under the class inspector pane.
  • Because the static tintColor property was removed in latest version of Interface builder. click '+', add tintColor in KeyPath, set the Type color and add your color.

Upvotes: 1

Mikea15
Mikea15

Reputation: 139

If you want the swift version.

UINavigationBar.appearance().tintColor = UIColor.whiteColor()

Also, if you want to apply this style to all your navigation view controllers. Put that code in your application didFinishLaunchingWithOptions method in your AppDelegate

Upvotes: 4

Esqarrouth
Esqarrouth

Reputation: 39181

Swift:

self.navigationController?.navigationBar.tintColor = UIColor.grayColor()

Upvotes: 1

Enrico Susatyo
Enrico Susatyo

Reputation: 19790

If you don't want to change the tint colour in the whole app and just want to do it on one navigation bar, do this:

self.navigationController.navigationBar.tintColor = [UIColor redColor];

Upvotes: 10

Simon Goldeen
Simon Goldeen

Reputation: 9080

The tint color property of a navigation bar determines the color of the text of its bar button items in iOS 7. The code you are looking for is something like this:

[[UINavigationBar appearance] setTintColor:[UIColor redColor]];

and, of course, replacing [UIColor redColor] with whatever color you want.

Upvotes: 35

Related Questions