我在iOS 11中使用新的扩大导航栏标题。但我似乎无法更改textColor。更改iOS 11大标题颜色
我试着这样做:
self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
这并没有做任何事情。有任何想法吗?
我在iOS 11中使用新的扩大导航栏标题。但我似乎无法更改textColor。更改iOS 11大标题颜色
我试着这样做:
self.navigationController.navigationBar.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
这并没有做任何事情。有任何想法吗?
self.navigationController.navigationBar.largeTitleTextAttributes = @{NSForegroundColorAttributeName: [UIColor whiteColor]};
不适合我:( –
我认为它还是在Xcode 9测试版中的错误6.
我发现不同的“解决方案”为它:
if #available(iOS 11.0, *) { UINavigationBar.appearance().largeTitleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.blue] }
if #available(iOS 11.0, *) { self.navigationController?.navigationBar.largeTitleTextAttributes = [NSAttributedStringKey.foregroundColor: UIColor.blue, NSAttributedStringKey.font: UIFont.systemFont(ofSize: 31, weight: UIFont.Weight.bold) ] }
希望它可以帮助你。
问候!
如果#available(iOS 11.0,*)找不到! –
你是否使用Xcode 9? –
是的,任何Xcode 9解决方案? –
[PrefersLargeTitles]设置为true时更改导航栏标题的文本颜色的可能副本(https://stackoverflow.com/questions/44619396/changing-the-text-color-of-a-导航栏 - 标题 - 当 - preferslargetitles-is-s) – Kqtr
有用于在Xcode中的错误,但它现在工作。完整的工作代码在这里:https://stackoverflow.com/a/48598246/7698127(这里没有发布答案,以避免重复的答案) – Kqtr