swift之彈出一個背景半透明的UIViewController


坑爹的背景半透明,按網上給出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

 

這樣成功半透明。  

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM