IOS How to copy player rotation in Youtube?

Any idea how the feature displayed in this video works ? It seems that touching the expand button changes the orientation of the device (in fact, when I sit down, I pull out the control center). In any case, only the video player seems to be spinning. The scrollview below it retains its portrait orientation.

+4
source share
1 answer

It looks like they represent a game controller with custom segue animation, having a player controller that only supports landscape.

Try to imagine a view controller that is implemented like this:

override func supportedInterfaceOrientations() -> Int {
  return Int(UIInterfaceOrientationMask.Landscape.rawValue)
}

override func preferredInterfaceOrientationForPresentation() -> UIInterfaceOrientation {
  return UIInterfaceOrientation.LandscapeLeft
}

override func shouldAutorotate() -> Bool {
  return false
}

Then the device should be in the landscape. All you have left is to make an animation of the user transition between the two, and you're done.

From the docs:

preferredInterfaceOrientationForPresentation

If your view controller implements this method, your view controllers view is shown in the preferred orientation.

0
source

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


All Articles