Actionsheet文本始终为灰色(NSAttributedString.Key不起作用)

问题描述 投票:0回答:1

我正在使用自定义操作表并显示一些文本。使用XCode 11.3,我不能使用NSAttributedString.Key.foreground。它以前在更新前就可以使用,但现在找不到解决方案。

Screengrab with example of my problem

    let attributedMessageText = NSMutableAttributedString(
        string: description,
        attributes: [
            NSAttributedString.Key.paragraphStyle: paragraphStyle,
            NSAttributedString.Key.font: UIFont.systemFont(ofSize: 13.0),
            NSAttributedString.Key.foregroundColor: UIColor.red
        ]
    )

如果我尝试更改背景色,它也会变成灰色。也许有人已经遇到了这个问题?

ios swift nsattributedstring actionsheet
1个回答
0
投票

使用私有API永远不是一个好主意,因为它们可能会更改,恕不另行通知。我猜你用这样的东西:

actionSheet.setValue(message, forKey: "attributedTitle")

这就是为什么这在iOS13.3上不起作用。不幸的是,没有合法的方法可以使用公共API更改这些颜色。但是您not alonehere是很好的建议

© www.soinside.com 2019 - 2024. All rights reserved.