简体   繁体   English

NSMutableAttributedString作为UIAlertAction的标题-Swift

[英]NSMutableAttributedString as UIAlertAction's title - Swift

Is it possible to set a NSMutableAttributedString as AlertAction's title? 是否可以将NSMutableAttributedString设置为AlertAction的标题? My aim is to visualize a math expression with a good design in my UIAlertAction's title. 我的目标是在UIAlertAction标题中可视化具有良好设计的数学表达式。

let action = UIAlertAction(title: myNSMutableAttributedString, style: UIAlertActionStyle.default) {(result : UIAlertAction) -> Void in

}

Thanks in advance for the help. 先谢谢您的帮助。

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 ). 在不访问私有API的情况下, 无法NSAttributedString用作UIAlertAction的标题,因为将attributedTitle设置为属性字符串的方法在这里不起作用( 有关此问题的详细信息,请参阅此问题 )。

I would create a custom class or use an alert library for this. 我将为此创建一个自定义类或使用警报库。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM