如何将约束设置为移动按钮

时间:2015-10-17 10:12:58

标签: ios iphone ios9

我正在为IOS开发游戏,它有3个按钮并随机移动所以我的问题是如何使用自动布局设置这些移动按钮的约束?

1 个答案:

答案 0 :(得分:0)

您应该添加IBOutlet NSLayoutConstraint,然后您可以使用按钮移动。任何这样的。

self.someView.constant = 30;
[self.view setNeedsUpdateConstraints];

[UIView animateWithDuration:0.25f animations:^{
    [self.view layoutIfNeeded];
}];