0
我使用PureLayout进行编程视图约束。我以为我让他们正确设置,大小,X和Y解决。但是,当我在SE上运行我的代码和7 Plus时,视图没有正确对齐。正确设置PureLayout约束?
下面是代码片段:
if (shouldSetupConstraints) {
// bg
backgroundView.autoPinEdgesToSuperviewEdges()
// positions
emailTextField.autoPinEdge(toSuperviewEdge: .top, withInset: 170)
emailTextField.autoPinEdge(toSuperviewEdge: .left, withInset: 60)
passwordTextField.autoPinEdge(toSuperviewEdge: .top, withInset: 250)
passwordTextField.autoPinEdge(toSuperviewEdge: .left, withInset: 60)
loginButton.autoPinEdge(toSuperviewEdge: .top, withInset: 350)
loginButton.autoPinEdge(toSuperviewEdge: .left, withInset: 75)
recoverButton.autoPinEdge(toSuperviewEdge: .top, withInset: 410)
recoverButton.autoPinEdge(toSuperviewEdge: .left, withInset: 60)
// confirms setup is done
shouldSetupConstraints = false
}
我认为屏幕分获视网膜上的屏幕一样,那么为什么会有差异与这些数字吗?
所以使用所有4个方向,但相同的值应该翻译,而不是从1定位? – jackdm
不要像现在这样使用相同的值,根据布局计算正确的值。 – the4kman
即时通讯不知道我得到你的意思,像一个如果其他取决于正在使用的设备? – jackdm