LoginSignup
57
49

More than 3 years have passed since last update.

モーダルビューをフルスクリーンで表示させる(iOS13以降)

Posted at

はじめに

iOS13からモーダル表示のデフォルト遷移方法が自動(UIModalPresentationStyle.automatic)に変更されました。

この変更で、デフォルトはフルスクリーンではなく、全面に重なるビューが表示されるようになりました。
(iPhone版のPageSheet表示!?)
UIModalPresentationStyle.pageSheet - UIModalPresentationStyle | Apple Developer Documentation

iOS12でのボイスメモアプリのように下方にスライドするだけでモーダル画面を消すことができるので、
大画面の端末での操作性は上がるでしょう。
しかし開発者側としてはレイアウトなどの関係で、いままでのフルスクリーンのままがよいと思う場面もあります。

そこでフルスクリーン表示に戻すを共有します。

方法

やり方は至極単純でUIViewControllerのmodalPresentationStyleを指定するだけです。

let vc = UIViewController()
// 遷移方法にフルスクリーンを指定
vc.modalPresentationStyle = .fullScreen
self.present(vc, animated: true, completion: nil)

modalPresentationStyle - UIViewController | Apple Developer Documentation

参照

viewcontroller - Presenting modal in iOS 13 fullscreen - Stack Overflow

57
49
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
57
49