类型"NSAttributedStringKey"(又名"NSString")没有成员"foregroundColor" [英] Type 'NSAttributedStringKey' (aka 'NSString') has no member 'foregroundColor'

查看:86
本文介绍了类型"NSAttributedStringKey"(又名"NSString")没有成员"foregroundColor"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

下面是上述问题的代码行. Swift 4.1中发生了此问题.

Below is line of code for the above mentioned issue. This issue is occurred in Swift 4.1.

let textAttributes = [NSAttributedStringKey.foregroundColor:UIColor.white]
navigationController?.navigationBar.titleTextAttributes = textAttributes

推荐答案

我已通过替换属性字符串的键来解决此问题.

I've fixed this problem by replacing the Key for Attributed String.

这是我更新后的代码:

let textAttributes = [NSForegroundColorAttributeName : UIColor.white]
navigationController?.navigationBar.titleTextAttributes = textAttributes

这篇关于类型"NSAttributedStringKey"(又名"NSString")没有成员"foregroundColor"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆