问题描述
是否可以将NSMutableAttributedString设置为AlertAction的标题?我的目标是在UIAlertAction标题中可视化设计良好的数学表达式.
Is it possible to set a NSMutableAttributedString as AlertAction's title?My aim is to visualize a math expression with a good design in my UIAlertAction's title.
let action = UIAlertAction(title: myNSMutableAttributedString, style: UIAlertActionStyle.default) {(result : UIAlertAction) -> Void in
}
预先感谢您的帮助.
推荐答案
不可能在不访问私有API的情况下将NSAttributedString
用作UIAlertAction
标题的方法将attributedTitle
设置为属性字符串在这里不起作用(有关此问题的详细信息,请参见此问题).
It's not possible to use an NSAttributedString
for a UIAlertAction
's title without accessing private APIs, as the method for setting the attributedTitle
to an attributed string does not work here (see this question for details on that).
我会为此创建一个自定义类或使用警报库.
I would create a custom class or use an alert library for this.
这篇关于NSMutableAttributedString作为UIAlertAction的标题-Swift的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!