【发布时间】:2017-06-20 21:19:29
【问题描述】:
我正在尝试以模态方式从控制器呈现自定义视图,但是当我这样做时,除了文本字段之外的所有内容的背景都会变成黑色,如 here 所示。 (the intended modal)
这似乎是一个相当普遍的问题,但是我已经实现了大多数类似问题作为答案的代码
这是我在第一个控制器中的 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 但我不认为这是你的问题
标签: ios swift swift3 modalviewcontroller