我试图改变UIAction工作表的背景颜色“取消”按钮,但它不起作用。下面是我的代码片段
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)发布于 2017-08-03 17:52:44
试试这个- let subView = alertController.view.subviews.first! Var alertContentView = subView.subviews.first! alertContentView.backgroundColor = UIColor.black alertContentView.layer.cornerRadius = 5
https://stackoverflow.com/questions/45371409
复制相似问题