我如何在模态中呈现viewController。我是ios的新手,我正在使用swift4 我试试这个
let userVC = mainStoryboard.instantiateViewController(withIdentifier:
"menuC") as! MenuController
userVC.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
userVC.navigationController?.modalPresentationStyle =
UIModalPresentationStyle.overCurrentContext
present(userVC, animated: true, completion: nil)
答案 0 :(得分:5)
这样做
if let presentedViewController = self.storyboard?.instantiateViewController(withIdentifier: "menuC") {
presentedViewController.providesPresentationContextTransitionStyle = true
presentedViewController.definesPresentationContext = true
presentedViewController.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext;
presentedViewController.view.backgroundColor = UIColor.init(white: 0.4, alpha: 0.8)
self.present(presentedViewController, animated: true, completion: nil)
}