如何在modaly swift 4中呈现ViewController
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了如何在modaly swift 4中呈现ViewController相关的知识,希望对你有一定的参考价值。
我如何在模态中呈现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)
答案
这样做
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)
}
以上是关于如何在modaly swift 4中呈现ViewController的主要内容,如果未能解决你的问题,请参考以下文章
如何在模态 swift 4 中呈现 ViewController
单击自定义 TableViewCell Swift 4 中的按钮时如何呈现单独的视图控制器?
如何使用 Swift 4.2 设置标志并将一些值从 Popup 呈现模型视图控制器传递到 Tabbar 主视图控制器?