2017-08-10 76 views

回答

3

你正在寻找的答案是UIStackView

Here is Apple Doc if you really want to go into it

实施UIStackView容易

1)选择你想要生效的所有视图像下面

Using UIStackview

3)设置你的UIStackView显示2)选择嵌入在Stackview图像

enter image description here

这里您UIStackview财产将如何样子。

enter image description here

UIStackView管理您的屏幕旋转,你可以有两个不同的布局,你的愿望。

1

你应该看看Size Classes的概念。例如,在YouTube上观看此视频以了解其工作原理。 https://youtu.be/7iT9fueKCJM

你也可以设置你的约束编程旋转后:

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 
     } 
    }