2017-08-10 92 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 
     } 
    }