I have totally different layouts for landscape and portrait.
In portrait the screen does not have the menu view of full height and half width on left and in landscape the screen contains the menu view on left side.
How to do that in iOS?
I have totally different layouts for landscape and portrait.
In portrait the screen does not have the menu view of full height and half width on left and in landscape the screen contains the menu view on left side.
How to do that in iOS?
2
Answers
You can do it programmatically, declare your menuContainer view under your class controller like that:
Now in viewDidLoad set constraints:
after that write the detect func (I add animation but you can’t do it):
override viewWillTransition func and call detectRotation func:
This is the result:
portrait
Landscape
To show in landscape and portrait:
The result:
If you only want to show menu on landscape.
Check the device orientation by:
UIDevice.current.orientation == .landscapeLeft || UIDevice.current.orientation == .landscapeRight
Then show the menu by using
menu.isHidden = false
to show the menu.You can set the menu constraints either using storyboard or programmatically.