Changing the Tint Color of UIBarButtonItem

后端 未结 8 1863
暗喜
暗喜 2020-12-15 03:31

I have a project using Storyboards and whenever I push a view controller with a segue, the dynamically created bar button item is always blue.

相关标签:
8条回答
  • 2020-12-15 03:51

    In iOS 8 if you changed UIView tint color for some purpose, for example for branding UIAlertView, tint color for UIBarButtonItem in UIToolBar also changed that way. To fix this, just write this code

    [UIView appearance].tintColor = SOME_COLOR;
    [UIView appearanceWhenContainedIn:[UIToolbar class], nil].tintColor = BLACK_COLOR;
    

    For UIBarButtonItem tint color in UINavigationBar use standard method

    [UINavigationBar appearance].tintColor = BLACK_COLOR;
    
    0 讨论(0)
  • 2020-12-15 03:54

    To change the color of a specific item (e.g. a button) in your nav bar: In Objective-C

    myButton.tintColor = [UIColor redColor];
    
    0 讨论(0)
提交回复
热议问题