简体   繁体   中英

NSMutableAttributedString as UIAlertAction's title - Swift

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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