ios - 仅使用 LayoutConstraints 来更改方向?

标签 ios swift nslayoutconstraint

当我使用 Storyboard 向按钮位置等添加约束时,我在方向变化上获得了 super 平滑的过渡。这些按钮移动到各自的新位置。

但我使用 view.translatesAutoresizingMaskIntoConstraints = true 在屏幕上移动元素。

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

我尝试使用以下方法使我的项目“粘”到屏幕底部,但没有成功。

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

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

最佳答案

使用 NSLayoutConstraint 似乎是正确的方法。 感谢 gnasher729 指出我只是错误地使用了它。

关于ios - 仅使用 LayoutConstraints 来更改方向?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34228193/

相关文章:

ios - 如何以编程方式为 en 和 ar 语言环境布局带有文本的 UIImageView?

ios - 以编程方式创建的 Animate NSLayoutConstraint

ios - 在后台创建新的 AVPlayer 不起作用?

swift - 对象不符合协议(protocol)

swift - 更改现有的 MKOverlays - 如何确定要更改的内容?

swift - MFMailComposeResult 常量不能在 Swift 2.3 中编译

swift - 在 Swift 中子类化 NSLayoutConstraint

objective-c - 如何在 Objective-C 中显示 PDF?

ios - 如何在 Xcode 中本地化 xcassets 文件夹中的图像

ios - iOS 上的 Android toast 消息