【问题标题】:NSMutableAttributedString as UIAlertAction's title - SwiftNSMutableAttributedString 作为 UIAlertAction 的标题 - Swift
【发布时间】:2017-09-03 10:16:17
【问题描述】:

是否可以将 NSMutableAttributedString 设置为 AlertAction 的标题? 我的目标是在 UIAlertAction 的标题中以良好的设计可视化数学表达式。

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

}

提前感谢您的帮助。

【问题讨论】:

  • Sooo 你试试怎么样?
  • 我输入了 title: String(describing: myNSMutableAttributedString) 但显然不是好方法

标签: ios swift string nsmutableattributedstring uialertaction


【解决方案1】:

不可能在不访问私有 API 的情况下将 NSAttributedString 用作 UIAlertAction 的标题,因为将 attributedTitle 设置为属性字符串的方法在此处不起作用( see this question for details on that)。

我会为此创建一个自定义类或使用警报库。

【讨论】:

  • 感谢您的回答。关于良好警报库的一些想法?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-12-08
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多