Present Full Screen on iOS 13 and above using extension

Mukesh Shakya
1 min readMay 1, 2020

--

iOS 13 got some really cool features for us but also it affected our already built app in some way. One of which effect is its default presentation style. Yes, it’s a cool looking presentation style right now but everytime we do not need such fancy stuff during a simple presentation.

Normal Presentation code

let vc = ViewController()
self.present(vc, animated: true)

The above block of code will present a full screen view controller only before iOS 13. In order to present a full screen view controller in iOS 13 and above the view controller’s modalPresentationStyle property default value is to be changed.

Fullscreen Presentation code in iOS 13 and above

let vc = ViewController()
if #available(iOS 13, *) {
vc.modalPresentationStyle = .fullScreen
}
self.present(vc, animated: true)

This is not what you are here for. Isn’t it? Let’s do it using extension so that we do not have to change viewcontroller’s modalPresentationStyle property checking the version every time we have to present a full screen view controller.

How to use the function in extension?

Just replace the use of default present function with our presentFullScreen function with similar arguments as the default present function.

let vc = ViewController()
self.presentFullScreen(vc, animated: true)

--

--

No responses yet