iosdev
iosdev

Reputation: 277

How to change the uibarbutton color in common

I want to have the uibarbutton color change consistent across all classes instead of having it be changed in each class? What should I do in the appdelegate?

Here is my code:

UIBarButtonItem *random1 = [[UIBarButtonItem alloc]initWithTitle:@"Back" style:UIBarButtonItemStyleBordered target:self action:@selector(back:)];
[random1 setTintColor:UIColorFromRGB(0xf63d78)];
self.navigationItem.leftBarButtonItem = random1;

Upvotes: 0

Views: 151

Answers (2)

Bernat
Bernat

Reputation: 1556

You should check the Appearance section in the official documentation (http://developer.apple.com/library/ios/#DOCUMENTATION/UIKit/Reference/UIBarButtonItem_Class/Reference/Reference.html).

But what you should do in this case is

[[UIBarButtonItem appearance] setTintColor:UIColorFromRGB(0xf63d78)];

Upvotes: 1

Pfitz
Pfitz

Reputation: 7344

Use UIAppearance proxy for such things. In your app delegate put the following.

[[UIBarButtonItem appearance] setTintColor:UIColorFromRGB(0xf63d78)];

Upvotes: 4

Related Questions