我试图从模式控制器呈现自定义视图,但是当我这样做时,除了文本框之外的所有内容的背景都变为黑色,如here中所示。 (the intended modal)Swift模式视图背景在设置为清除后出现黑色
这似乎是一个相当普遍的问题,但是我已经执行,大多数类似的问题提出的答案
这里的代码是在第一个控制器我的addEvent方法:
@IBAction func addEvent(_ sender: Any) {
let newEventViewController = NewEventViewController()
newEventViewController.view.backgroundColor = UIColor.clear
newEventViewController.view.isOpaque = false
navigationController?.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
navigationController?.present(newEventViewController, animated: true, completion: nil)
}
任何帮助搞清楚我失踪将不胜感激。如果它有所作为,我正在使用单独的xib文件创建我的应用程序,而不是故事板。
灿提供更多信息?你有没有试过self.present ...?也设置self.modalPresentationStyle 通常isOpaque和backgroundColor应设置viewDidLoad,但我不认为这是你的问题 – Jeremie