How to imagine the landscape only ViewController from the bottom of the iPhone portfolio in swift?

I have only a single screen portrait app in landscape only mode.

What I did: I created a subclass of UINavigationController and redefined the following:

import UIKit

class LandscapeVCNavigationController: UINavigationController {

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    override var supportedInterfaceOrientations: UIInterfaceOrientationMask {
        return .landscape
    }
    override var preferredInterfaceOrientationForPresentation: UIInterfaceOrientation {
        return .landscapeLeft
    }
}

Then, using this navigationController to present your landscape view manager as follows:

if let vc = storyboard?.instantiateViewController(withIdentifier: StoryBoardIdentifiers.playerVCStoryboardIdentifier) as? PlayerViewController {

            let navController = LandscapeVCNavigationController.init(rootViewController: vc)

            present(navController, animated: true, completion: {
            })
        }

This works great.

What I need:

I need a landscape VC, which will be presented from below (the main button on the button), and should deviate to the bottom (home button). This is what is happening now.

enter image description here

+4
source share
1 answer

, .

    let transition = CATransition()
    transition.duration = 0.3
    transition.timingFunction = CAMediaTimingFunction(name:kCAMediaTimingFunctionEaseInEaseOut)
    transition.type = kCATransitionPush
    transition.subtype = kCATransitionFromLeft
    self.view!.window!.layer.add(transition, forKey: nil)
    self.present(navController, animated: false, completion:nil) 
+1

Source: https://habr.com/ru/post/1679503/


All Articles