在第一个ViewController做如下设置
let controller = UIStoryboard(name: "Main", bundle: nil).instantiateViewControllerWithIdentifier("SecondViewController") as! SecondViewController controller.view.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.6)
self.modalPresentationStyle = UIModalPresentationStyle.FullScreen
self.presentViewController(controller, animated: true, completion:nil) 到SecondViewController的ViewDidLoad()方法内添加以下代码,不然的话视图加载完后背影又变成了黑色
self.modalPresentationStyle = .Custom