NSMutableAttributedString as UIAlertAction's title - Swift

ε祈祈猫儿з 提交于 2019-12-11 18:27:41

问题


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

}

Thanks in advance for the help.


回答1:


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.



来源:https://stackoverflow.com/questions/46022379/nsmutableattributedstring-as-uialertactions-title-swift

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!