Ios – How to set color `rightBarButtonItem` on navigation bar

iosiphoneobjective cswiftuinavigationbar

I want to set color of "Done" button on navigation bar like this image:

enter image description here

Although, I've set code as self.doneButton.enabled = NO; but Done button still has a white color. It does not change color like image.

How to set the code to change text color done button like Done button in the image above?
Please help me to solve this problem. I appreciate your help.

Best Answer

for change the color of barbutton use

objective C

self.navigationItem.rightBarButtonItem = yourRightbarbuttonName;
self.navigationItem.rightBarButtonItem.tintColor = [UIColor blueColor]; // add your color

Swift

or set from Story board Set bat button color

self.navigationItem.rightBarButtonItem = yourRightbarbuttonName
self.navigationItem.rightBarButtonItem.tintColor = UIColor.blueColor()

if you want to show the Right barbutton use

objective C

self.navigationItem.rightBarButtonItem.enabled = YES;

Swift

self.navigationItem.rightBarButtonItem.enabled = true

if you want to hide the Right barbutton use

objective C

self.navigationItem.rightBarButtonItem.enabled = NO;

Swift

self.navigationItem.rightBarButtonItem.enabled = false