오늘도 프로젝트를 수행하다가 자주 잊어버리는 코드를 기억하기 위해 포스팅을 작성한다! 바로 present로 화면 이동 했을 때 화면 이동하여 새로 나타나는 화면을 full screen으로 설정하고 싶을 때 사용하는 코드!
이 글에서 present하는 방법 보다는 fullscreen에 초점이 맞춰있다.
해당 화면을 fullscreen으로 설정하기 위해서는 먼저 알아야할 것이 있다. 바로 UIModalPresentationStyle!
바로 애플 공식 문서 드가자~
UIModalPresentationStyle
Modal presentation styles available when presenting view controllers.
view controller를 present할 때 이용가능한 모달 창을 보여주는 스타일
UIModalPresentationStyle 옵션 종류는 다음과 같다. 여기에서 present했을 때 보여주고 싶은 modal 창의 style을 선택하면된다.
- case automatic
The default presentation style chosen by the system.
- case none
A presentation style that indicates no adaptations should be made.
- case fullScreen
A presentation style in which the presented view covers the screen.
- case pageSheet
A presentation style that partially covers the underlying content.
- case formSheet
A presentation style that displays the content centered in the screen.
- case currentContext
A presentation style where the content is displayed over another view controller’s content.
- case custom
A custom view presentation style that is managed by a custom presentation controller and one or more custom animator objects.
- case overFullScreen
A view presentation style in which the presented view covers the screen.
- case overCurrentContext
A presentation style where the content is displayed over another view controller’s content.
- case popover
A presentation style where the content is displayed in a popover view.
- case blurOverFullScreen
A presentation style that blurs the underlying content before displaying new content in a full-screen presentation.
내가 사용하고 싶은 스타일을 fullscreen 방식!
사용하는 방법은 present될 viewcontroller의 UIModalPresentationStyle를 fullscreen으로 적용해주면 되겠다!
let newViewController = self.storyboard!.instantiateViewController(identifier: "LoadingViewController")
newViewController.modalPresentationStyle = UIModalPresentationStyle.fullScreen
self.present(newViewController, animated: false)
오늘은 여기서 끄읏~!