ios-swift之弹出一个背景半透明的UIViewController

let viewController=storyboard.instantiateViewControllerWithIdentifier("对应要启动的ViewController名字") as 对应要启动的ViewController名字
viewController.view.backgroundColor = UIColor(red: 0, green: 0, blue: 0, alpha: 0.5)
self.presentViewController(vPersonalizedSettingsViewController, animated: 动不动画随便你, completion: nil)

这里要注意的是,要启动的viewController必须要在这里设置半透明,如果在对应的UIViewController viewDidLoad里面设置是没有半透明的!

然后在要启动的UIViewController viewDidLoad里设置

self.modalPresentationStyle = .Custom

猜你喜欢

转载自blog.csdn.net/wa172126691/article/details/80327553
今日推荐