首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何更改UIAction工作表取消按钮背景颜色

如何更改UIAction工作表取消按钮背景颜色
EN

Stack Overflow用户
提问于 2017-07-28 18:43:58
回答 1查看 92关注 0票数 0

我试图改变UIAction工作表的背景颜色“取消”按钮,但它不起作用。下面是我的代码片段

代码语言:javascript
复制
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)
EN

回答 1

Stack Overflow用户

发布于 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

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45371409

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档