开发者

UINavigationBar buttons color [duplicate]

开发者 https://www.devze.com 2022-12-17 02:02 出处:网络
This question already has answers here: How to change the text color on UINavigationBar button items (8 answers)
This question already has answers here: How to change the text color on UINavigationBar button items (8 answers) 开发者_StackOverflow社区 Closed 3 years ago.

How to change the color of the button in the UINavigationBar? For example, I use UINavigationBar with light gray background, and I need the buttons to be dark gray (almost black). It will be cool to have one solution for all button types, i.e. back button, button with image, button with text

thanks


This is a terrible hack but, when placed in -viewDidAppear: method(s), it will change the background color (tint, actually) of UINavigationButtons.

UINavigationBar *navBar = [[self navigationController] navigationBar];
for (UIView *subview in [navBar subviews])
    {
    if ([NSStringFromClass([subview class]) isEqualToString:@"UINavigationButton"])
        {
        if (![[subview title] isEqualToString:@"Done"])
            [subview setTintColor:[UIColor colorWithRed:255.0/255.0 green:0.0/255.0 blue:0.0/255.0 alpha:1.0]];
        }
    }

It will not however change tint for UINavigationItemButtonViews - and this is what is used for the navigation back buttons. If someone finds a way to affect them, please let me know.

0

精彩评论

暂无评论...
验证码 换一张
取 消