我的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)谢谢!

发布于 2017-04-03 01:21:51
这是丑陋和错误的设计。您应该创建一个自定义视图控制器,并将您的pick控制器添加到其中。将背景更改为透明,并将模态表示样式设置为“超过当前上下文”以显示自定义视图控制器。
self.modalPresentationStyle = UIModalPresentationStyle.OverCurrentContexthttps://stackoverflow.com/questions/43174842
复制相似问题