Presenting modal in iOS 13 fullscreen

懵懂的女人 提交于 2019-11-27 05:15:35
pascalbros

With iOS 13, as stated in the Platforms State of the Union during the WWDC 2019, Apple introduced a new default card presentation. In order to force the fullscreen you have to specify it explicitly with:

let vc = UIViewController()
vc.modalPresentationStyle = .fullScreen
self.present(vc, animated: true, completion: nil)

I add an information that could be useful for someone. If you have any storyboard segue, to go back to the old style, you need to set the kind property to Present Modally and the Presentation property to Full Screen.

In Objective-C two ways I have found.

I notice that the two enum modalPresentationStyles are all less than zero

UIModalPresentationNone API_AVAILABLE(ios(7.0)) = -1,

UIModalPresentationAutomatic API_AVAILABLE(ios(13.0)) = -2,

  • override your base ViewController method (I suggest)
- (void)presentViewController:(UIViewController *)viewControllerToPresent animated:(BOOL)flag completion:(void (^)(void))completion
{
    if (viewControllerToPresent.modalPresentationStyle < 0){
        viewControllerToPresent.modalPresentationStyle = UIModalPresentationFullScreen;
    }
    [super presentViewController:viewControllerToPresent animated:flag completion:completion];
}
  • method exchange
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!