我想更改CATextLayer的文本颜色.
这不起作用
myTextLayer.textColor
Run Code Online (Sandbox Code Playgroud)
因为没有这样的财产.通过设置前景色我也没有回应
textLayer.foregroundColor = someColor.CGColor
Run Code Online (Sandbox Code Playgroud)
当文本层设置如下
let myAttribute = [ NSFontAttributeName: UIFont(name: mongolFontName, size: fontSize )! ]
let attrString = NSMutableAttributedString(string: textLayer.displayString, attributes: myAttribute )
textLayer.frame = myFrame
textLayer.string = attrString
Run Code Online (Sandbox Code Playgroud)
我已经看到Objective-C问题CATextLayer textcolor总是黑色的,但那里的答案在我的情况下似乎没有意义.
由于我能够通过阅读文档解决我的问题,我将在下面分享答案.