坑爹的背景半透明,按網上給出oc的方法,動畫結束之后,半透明效果消失。通過各種折騰,各種試驗,終於搞定了。
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
這樣成功半透明。