首页 > 技术文章 > 弹出的ViewController半透明效果

foxting 2015-11-06 16:42 原文

在第一个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

 

推荐阅读