【问题标题】:How to change these colors on Navbar?如何在导航栏上更改这些颜色?
【发布时间】:2014-07-17 06:53:04
【问题描述】:

我已成功更改导航栏按钮:

[[UINavigationBar appearance] setBarTintColor:[UIColor colorWithRed:26.0/255 green:132.0/255 blue:182.0/255 alpha:.5]];

如果我想改变标题的颜色(从黑色)或按钮的颜色呢?

【问题讨论】:

标签: ios ios7 uinavigationcontroller uinavigationbar


【解决方案1】:

这就是我的 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]}];

【讨论】:

    【解决方案2】:

    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/

    【讨论】:

      猜你喜欢
      • 2020-11-09
      • 2018-02-06
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多