美文网首页
iOS 更改UIAlertAction 标题颜色

iOS 更改UIAlertAction 标题颜色

作者: 麓庵 | 来源:发表于2019-03-20 12:32 被阅读0次

更改 UIAlertAction 标题颜色

1 使用 open func setValue(_ value: Any?, forKey key: String) 方法

        let action = UIAlertAction.init(title: "Cancel", style: .cancel, handler: nil)
        action.setValue(UIColor.green, forKey: "_titleTextColor")
        // key 可以是  titleTextColor 或者是 _titleTextColor

2 继承 UIAlertController, 在 func addAction(_ action: UIAlertAction) 方法中改标题颜色

 override func addAction(_ action: UIAlertAction) {
        super.addAction(action)
       self.view.tintColor = UIColor.init(clarifyColor: .LightBlue5BC9E8)
 }

相关文章

网友评论

      本文标题:iOS 更改UIAlertAction 标题颜色

      本文链接:https://www.haomeiwen.com/subject/sbhzmqtx.html