gpt4 book ai didi

swift - UIAlertAction 背景颜色

转载 作者:行者123 更新时间:2023-11-28 15:45:17 30 4
gpt4 key购买 nike

我的 UIAlertController 有问题,它没有正确显示背景颜色...你能帮我吗?

这是代码:

let alert = UIAlertController(title: "Choose qty", message: "", preferredStyle: UIAlertControllerStyle.alert)
let pickerController = PickerQtyController()
alert.setValue(pickerController, forKey: "contentViewController")
// Testing color
alert.view.tintColor=UIColor.blue
let backView = alert.view.subviews.last?.subviews.last
backView?.layer.cornerRadius = 10.0
backView?.backgroundColor = UIColor.blue
// Btns
let saveBtn = UIAlertAction(title: "Save", style: UIAlertActionStyle.default) {
UIAlertAction in
print("UIAlertController: Saved")
pickerController.saveNewValueOfPicker()
}
let cancelBtn = UIAlertAction(title: "Cancel", style: UIAlertActionStyle.cancel) {
UIAlertAction in
print("UIAlertController: Canceled")
}
alert.addAction(saveBtn)
alert.addAction(cancelBtn)
self.present(alert, animated: true)

谢谢!

最佳答案

这是丑陋且错误的设计。您应该创建一个自定义 View Controller 并将您的选择 Controller 添加到其中。将背景更改为透明并将模态呈现样式设置为覆盖当前上下文以显示自定义 View Controller 。

self.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContext

关于swift - UIAlertAction 背景颜色,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43174842/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com