Presenting modal in iOS 13 fullscreen

后端 未结 30 2180
囚心锁ツ
囚心锁ツ 2020-11-21 06:48

In iOS 13 there is a new behaviour for modal view controller when being presented.

Now it\'s not fullscreen by default and when I try to slide down, the app just dis

30条回答
  •  自闭症患者
    2020-11-21 07:19

    The above answers and suggestions are right, below is another version, and efficient way using programmatically.

    #1 Created a UIView Extension

    #2 Created a Method ()

    //#1
    extension UIViewController {
    
    //#2
    func presentLocal(_ viewControllerToPresent: UIViewController, animated flag: 
    Bool, completion: (() -> Void)? = nil) {
    
    //Reusing below 2 lines :-)
    viewControllerToPresent.modalPresentationStyle = .overCurrentContext
    self.present(viewControllerToPresent, animated: flag, completion: completion)
    
      }
    }
    

    Invoking as below

    let vc = MyViewController()
    let nc = UINavigationController(rootViewController: vc)
    sourceView.presentLocal(nc, animated: true, completion: nil)
    

    OR

    let vc = MyViewController()
    sourceView.presentLocal(vc, animated: true, completion: nil)
    

提交回复
热议问题