HUD中的文字颜色

时间:2019-06-24 10:23:42

标签: ios swift

这是我的代码:

HTTP/2 200 
date: Mon, 24 Jun 2019 10:11:39 GMT
content-type: text/html; charset=UTF-8
content-length: 1952
server: nginx
x-powered-by: Express
cache-control: public, max-age=0
last-modified: Tue, 21 May 2019 10:11:37 GMT
vary: Accept-Encoding
x-frame-options: SAMEORIGIN
strict-transport-security: max-age=31536000
x-content-type-options: nosniff
x-xss-protection: 1; mode=block;
accept-ranges: bytes

HUD中的文本颜色为黑色。为什么以及如何将其更改为白色?

3 个答案:

答案 0 :(得分:2)

您应该使用NSAttributedString.Key而不是CoreText键来尝试替换以下内容:

let attribs = [ kCTFontAttributeName: UIFont.systemFont(ofSize: 66.0), kCTForegroundColorAttributeName: UIColor.white]

与此:

let attribs: [NSAttributedString.Key: Any] = [.font: UIFont.systemFont(ofSize: 66.0),
                                              .foregroundColor: UIColor.green]

答案 1 :(得分:0)

您可以在此行更改

let attribs = [ kCTFontAttributeName: UIFont.systemFont(ofSize: 66.0), kCTForegroundColorAttributeName: UIColor.white.CGColor]

应用此属性的文本的前景色。与此属性关联的值必须是CGColor对象。默认值为黑色。 Refer here

答案 2 :(得分:0)

尝试一下:

let attribs = [NSAttributedString.Key.font.rawValue:UIFont.systemFont(ofSize:66.0),NSAttributedString.Key.foregroundColor:UIColor.white]一样! [String:任何]