【问题标题】:How to change UIAction sheet Cancel button background color如何更改 UI 操作表取消按钮背景颜色
【发布时间】:2017-07-28 10:43:58
【问题描述】:

我试图更改 UIAction 表“取消”按钮的背景颜色,但它不起作用。 这是我的代码 sn-p

if let subview = alertController.view.subviews.first, let alertContentView = subview.subviews.first {
    for innerView in alertContentView.subviews {
        innerView.backgroundColor =  UIColor.red//StyleKit.popoverDefaultBackgroundColor
        //drop shadow
        innerView.layer.masksToBounds = false
        innerView.layer.shadowOpacity = 0.8
    }
}
let subview = alertController.view.subviews.last! as UIView
let alertContentView = subview.subviews.last! as UIView
alertContentView.backgroundColor = UIColor.black

let cancelAction = UIAlertAction(title: "Cancel".localize(), style: .cancel)

alertController.addAction(changeAction)
alertController.addAction(cancelAction)

【问题讨论】:

标签: iphone swift3.2


【解决方案1】:

试试这个 - let subView = alertController.view.subviews.first! Var alertContentView = subView.subviews.first! alertContentView.backgroundColor = UIColor.black alertContentView.layer.cornerRadius = 5

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-01
    • 2015-06-04
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多