根据在 iOS 上实现暗模式,我们需要将 foregroundColor 属性设置为新的标签颜色。这是如何使用界面生成器完成的?
我尝试使用“文本颜色”选项并将颜色设置为 Developer->labelColor,但这不起作用。
编辑:由于目前这是不可能的,我使用了这个解决方法:
override func viewDidLoad() {
// Support Dark Mode
if #available(iOS 13.0, *) {
let attributes = NSMutableAttributedString(attributedString: textView.attributedText!)
attributes.addAttribute(.foregroundColor, value: UIColor.label, range: NSRange(location: 0, length: attributes.mutableString.length))
textView.attributedText = attributes
}
}