Type 'NSAttributedStringKey' (aka 'NSString') has no member 'foregroundColor'

∥☆過路亽.° 提交于 2019-12-13 04:43:36

问题


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

回答1:


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

Here is my updated Code is:

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


来源:https://stackoverflow.com/questions/50325873/type-nsattributedstringkey-aka-nsstring-has-no-member-foregroundcolor

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!