How to change navigation bar color in iOS 7 or 6?

后端 未结 16 1810
你的背包
你的背包 2020-12-07 14:33

I want to change the color of the navigation bar color, but I\'m not sure whether or not I should change the tint or the background. I know iOS 7 is going for a more flat de

16条回答
  •  青春惊慌失措
    2020-12-07 15:15

    Based on posted answered, this worked for me:

    /* check for iOS 6 or 7 */
    if ([[self navigationController].navigationBar respondsToSelector:@selector(setBarTintColor:)]) {
        [[self navigationController].navigationBar setBarTintColor:[UIColor whiteColor]];
    
    } else {
        /* Set background and foreground */
        [[self navigationController].navigationBar setTintColor:[UIColor whiteColor]];
        [self navigationController].navigationBar.titleTextAttributes = [[NSDictionary alloc] initWithObjectsAndKeys:[UIColor blackColor],UITextAttributeTextColor,nil];
    }
    

提交回复
热议问题