In portrait mode I have four views on top of one another from the top to the bottom of the view controller (see image).
I then want to change the position of the views relative to one another when the device transitions to landscape (see image two).
I want view 4 to move alongside views 2 and 3 and them all the sit below view 1.
Some of the layout conditions:
- view 1 is attached to the top of the view controller in both landscape and portrait.
- view 4 is attached to the left, right and bottom margins of the view controller in portrait mode.
- Views 2, 3 & 4 are centered horizontally within the portrait view.
What is the best method to achieve the different layouts?
Would the most elegant solution be to make a reference to the constraints in the view controllers code and activate and deactivate them in viewWillTransition? Or is there a way to use vary for traits to achieve this (I can imagine views 2, 3 & 4 being centered horizontally would make this hard to achieve, as well as adding the new constraints for view 4 in landscape mode)?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…