【发布时间】:2017-02-27 14:29:33
【问题描述】:
嗨,我正在以编程方式添加一些这样的视图
let xPos = (self.view.frame.size.width - 200)/2
self.headerLabel = UILabel(frame: CGRect(x: xPos, y: 50.0, width: 200.0, height: 100.0))
self.shopButton = UIButton(frame: CGRect(x: xPos, y: 150.0, width: 200.0, height: 40.0))
self.createButton = UIButton(frame: CGRect(x: xPos, y: 230.0, width: 200.0, height: 40.0))
self.orLabel = UILabel(frame: CGRect(x: xPos, y: 200.0, width: 200.0, height: 20.0))
问题是当我将设备旋转到横向模式时,反之亦然,我的视图与左侧对齐。如何预防?
【问题讨论】:
标签: ios swift views programmatically-created