我试图将一些属性设置为 NSAttributedString。除前景色外,一切正常。
这就是我尝试设置属性的方式:
func setLabelText(text:String){
let strokeTextAttributes = [
NSAttributedString.Key.strokeColor : UIColor.white,
NSAttributedString.Key.foregroundColor : UIColor.red,
NSAttributedString.Key.font : UIFont.init(name: "Raleway-ExtraBold", size: 26)!,
NSAttributedString.Key.strokeWidth : 0.5,
]
as [NSAttributedString.Key : Any]
label.attributedText = NSMutableAttributedString(string: text, attributes: strokeTextAttributes)
}
正如您在图像中看到的那样,它没有设置文本颜色:
你知道为什么它会忽略foregroundColor 属性吗?
提前致谢。