仅使用LayoutConstraints进行方向更改?

时间:2015-12-11 16:29:44

标签: ios swift nslayoutconstraint

当我使用故事板向按钮位置等添加约束时,我会在方向更改时获得超级平滑的过渡。按钮移动到新的位置。

但是我使用view.translatesAutoresizingMaskIntoConstraints = true来移动屏幕周围的元素。

现在我几乎开始为定向更改编写自定义动画逻辑。但必须有一些更简单的方法!?我可以在方向改变之前转动约束并在之后再次提起它们吗?

我尝试使用以下内容来制作我的项目'坚持'在屏幕的底部,但它没有工作。

NSLayoutConstraint(item: super.bottomLayoutGuide, attribute: .Top, relatedBy: .Equal, toItem: self.centerPositionButton, attribute: NSLayoutAttribute.Bottom, multiplier: 1.0, constant: 20)

我目前正在尝试很多东西,但有些东西告诉我,我不能成为第一个尝试这个的人。

1 个答案:

答案 0 :(得分:0)

使用void* s似乎是正确的方法。 谢谢你gnasher729指出我只是错误地使用它。