Swift:在 UIAlertContorller 消息中将文本设为粗体

DG7*_*DG7 2 ios swift

我正在制作 Android 应用程序的 iOS 版本。我想让我正在通过的字符串变成粗体。在另一个应用程序中,它是通过添加 html 来完成的,如下所示。我尝试了这个,但没有成功。有没有办法实现这个或可能解决这个问题?

旁注:showPrompt 是我为 UIAlertController 功能所做的开关。

谢谢,

func systemUpdateCheck(oCurVer: String){    

    showPrompt("A new version has been released,<b>v." + oCurVer + "<b>.<br/>Tap OK to download and install the new version", sType: "alert", sJSResp: "")
}
Run Code Online (Sandbox Code Playgroud)

小智 6

尝试这个

let attributedText = NSMutableAttributedString(string: "Message", attributes: [NSAttributedStringKey.font: UIFont(name:".SFUIText-BoldItalic", size: 12)!])
let alert = UIAlertController(title: "Title", message: "", preferredStyle: .alert)
alert.setValue(attributedText, forKey: "attributedMessage")
let okAction = UIAlertAction(title: LocalizedString("Ok"), style: .default)
alert.addAction(okAction)
present(alert, animated: true)
Run Code Online (Sandbox Code Playgroud)