iOS 更改UIAlertAction 标题颜色

2019-03-20  本文已影响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)
 }
上一篇 下一篇

猜你喜欢

热点阅读