Reputation: 4448
In My project
change orientation will change UIView Design for same ViewController
Portrait:
in same ViewController change the design for different orientation styles.
Upvotes: 1
Views: 1077
Reputation: 3008
The answer you are looking for is UIStackView
Here is Apple Doc if you really want to go into it
Implementing UIStackView is easy
1) Select the all views you want to take effect 2) Select Embed in Stackview like displayed in image below
3) Setup your UIStackView
Here how your UIStackview property will look like.
UIStackView manage your screen rotation and you can have two different layouts as you desire.
Upvotes: 4
Reputation: 2513
You should look at Size Classes concept. For example, watch this video on youtube to understand how it works. https://youtu.be/7iT9fueKCJM
Also you can setup your constraints programmatically after rotation:
override func viewWillTransitionToSize(size: CGSize, withTransitionCoordinator coordinator: UIViewControllerTransitionCoordinator) {
super.viewWillTransitionToSize(size, withTransitionCoordinator: coordinator)
if (UIDevice.currentDevice().orientation.isLandscape) {
// ------ Landscape -----
// Setup constraints
} else {
// ----- Portrait -----
// Setup constraints
}
}
Upvotes: 2