我正在尝试在MDCAlertController
包含粗体字的单词上设置属性消息。但是,iOS 上的 Material Components 库似乎忽略了它,我不知道为什么。
这是我正在使用的代码,下面我提供了结果的屏幕截图。
let message = "This should be bold"
let attributedString = NSMutableAttributedString(string: message, attributes: [
.font: UIFont.systemFont(ofSize: 14)
])
attributedString.addAttribute(
.font,
value: UIFont.boldSystemFont(ofSize: 14),
range: (message as NSString).range(of: "bold")
)
let alert = MDCAlertController(
title: "Example alert",
attributedMessage: attributedString
)
alert.addAction(MDCAlertAction(title: "OK"))
present(alert, animated: true)