1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

modal遷移をフルスクリーンで、下から出ないように行う

Posted at

全画面で遷移したいとき、下から出したくないとき、ありますよね。
以下はUIButtonaddTargetし、遷移する関数です。

@objc func buttonTapped() {
        let nextVC = nextViewController()
        nextVC.modalTransitionStyle = UIModalTransitionStyle.crossDissolve
        nextVC.modalPresentationStyle = UIModalPresentationStyle.fullScreen
        self.navigationController?.pushViewController(nextVC, animated: true)
    }

UIModalTransitionStyleは列挙型で、は遷移アニメーションを指定することができます。

public enum UIModalTransitionStyle : Int {

    case coverVertical = 0

    case flipHorizontal = 1

    case crossDissolve = 2

    @available(iOS 3.2, *)
    case partialCurl = 3
}

デフォルトではcoverVerticalが設定されているので、自然に遷移する(?)crossDissolveに変えます。

同様にmodalPresentationStyleも列挙型の中からfullScreenに変更します。

ちなみにmodalPresentationStyleは以下のように書かれています。

public enum UIModalPresentationStyle : Int {

    
    case fullScreen = 0

    @available(iOS 3.2, *)
    case pageSheet = 1

    @available(iOS 3.2, *)
    case formSheet = 2

    @available(iOS 3.2, *)
    case currentContext = 3

    @available(iOS 7.0, *)
    case custom = 4

    @available(iOS 8.0, *)
    case overFullScreen = 5

    @available(iOS 8.0, *)
    case overCurrentContext = 6

    @available(iOS 8.0, *)
    case popover = 7

    
    @available(iOS 7.0, *)
    case none = -1

    @available(iOS 13.0, *)
    case automatic = -2
}
1
1
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
1
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?