【问题标题】:How to present ViewController in modaly swift 4如何在模态 swift 4 中呈现 ViewController
【发布时间】:2017-12-22 04:59:30
【问题描述】:

如何以模态显示 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)

【问题讨论】:

    标签: ios xcode uiviewcontroller swift4


    【解决方案1】:

    这样做

    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)
        }
    

    【讨论】:

      猜你喜欢
      • 2018-03-07
      • 1970-01-01
      • 1970-01-01
      • 2017-07-26
      • 1970-01-01
      • 2016-11-14
      • 1970-01-01
      • 1970-01-01
      • 2015-04-26
      相关资源
      最近更新 更多