我已成功更改导航栏按钮:
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:26.0/255 green:132.0/255 blue:182.0/255 alpha:.5]];
如果我想更改标题的颜色(从黑色)或按钮的颜色怎么样?
答案 0 :(得分:2)
这是我在App Delegate中的一个专门用于改变外观的方法。
// set button tint colour to white
[[UINavigationBar appearance] setTintColor:[UIColor whiteColor]];
// set the bar tint colour to purplish
[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:.2 green:.458823529 blue:.592156863 alpha:1.0]];
// set title text label colour to white
[[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName : [UIColor whiteColor]}];
答案 1 :(得分:1)
对于iOS7中的导航栏标题颜色,您应该使用UINavigationBar外观的setTitleTextAttributes
NSShadow *shadow = [[NSShadow alloc] init];
shadow.shadowColor = [UIColor colorWithRed:0.0 green:0.0 blue:0.0 alpha:0.8];
shadow.shadowOffset = CGSizeMake(0, 1);
[[UINavigationBar appearance] setTitleTextAttributes: [NSDictionary dictionaryWithObjectsAndKeys:[UIColor colorWithRed:245.0/255.0 green:245.0/255.0 blue:245.0/255.0 alpha:1.0], NSForegroundColorAttributeName,shadow, NSShadowAttributeName, [UIFont fontWithName:@"HelveticaNeue-CondensedBlack" size:21.0], NSFontAttributeName, nil]];
有关更多导航栏自定义的信息,请参阅http://www.appcoda.com/customize-navigation-status-bar-ios-7/