IOS迅速变化的方向会改变的UIView设计
问题描述:
答
你正在寻找的答案是UIStackView
Here is Apple Doc if you really want to go into it
实施UIStackView容易
1)选择你想要生效的所有视图像下面
3)设置你的UIStackView显示2)选择嵌入在Stackview图像
这里您UIStackview财产将如何样子。
UIStackView管理您的屏幕旋转,你可以有两个不同的布局,你的愿望。
答
你应该看看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
}
}
这是什么问题?如何做到这一点?所以广场不只是改变方向而是相互定位?在IB还是代码? – agibson007