【问题标题】:change the view controller title color in objective c更改目标 c 中的视图控制器标题颜色
【发布时间】:2017-12-09 08:50:38
【问题描述】:

我想将视图控制器标题颜色更改为黑色!

【问题讨论】:

标签: ios user-interface uiviewcontroller


【解决方案1】:

试试这个在 viewWillAppear 函数中添加这个代码:-

根据你的字体传递字体名称

[self.navigationController.navigationBar setTitleTextAttributes:
 @{NSForegroundColorAttributeName:[UIColor blackColor],
NSFontAttributeName:[UIFont fontWithName:@"Helvetica-regular" size:17]}];

【讨论】:

    【解决方案2】:

    只有一个视图控制器的标题颜色变化:

    在viewWillAppear中使用下面的代码

    [self.navigationController.navigationBar setTitleTextAttributes:
     @{NSForegroundColorAttributeName:[UIColor blackColor]}];
    

    整个应用程序的标题颜色变化:

    在didFinishLaunching中使用下面的代码

    [[UINavigationBar appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor]}];
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-08-23
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多