首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >如何在modaly swift 4中呈现ViewController

如何在modaly swift 4中呈现ViewController
EN

Stack Overflow用户
提问于 2017-12-22 12:59:30
回答 1查看 9.7K关注 0票数 5

如何在模式中呈现viewController。我是ios的新手,正在使用swift4,我试了一下

代码语言:javascript
复制
 let userVC = mainStoryboard.instantiateViewController(withIdentifier: 
  "menuC") as! MenuController
    userVC.modalPresentationStyle = UIModalPresentationStyle.overCurrentContext
      userVC.navigationController?.modalPresentationStyle = 
    UIModalPresentationStyle.overCurrentContext
    present(userVC, animated: true, completion: nil)
EN

回答 1

Stack Overflow用户

发布于 2017-12-22 13:00:23

像这样做

代码语言:javascript
复制
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)
    }
票数 10
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47936039

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档