【发布时间】:2015-09-08 17:35:29
【问题描述】:
【问题讨论】:
标签: ios objective-c swift cocoa-touch uiview
【问题讨论】:
标签: ios objective-c swift cocoa-touch uiview
在 Sort2 按钮的选择器中,添加行
[UIView animateWithDuration:1.0 animations:^{
sort2View.center = CGPointMake(sort1View.center.x, sort1View.center.y + 50)
}];
另一种更简洁的方法是添加UIConstraints。
【讨论】:
使用布局约束有更好的方法。您应该在 Sort2 和您的视图之间提供中心约束,并将其优先级设置为高。之后,在 Sort1 和您的视图之间设置中心约束,并将其优先级设置为低。之后,您只需使用此代码更改他们的优先级。 (在代码中,yourView 是你的整个视图,包括这三个视图)
[UIView animateWithDuration:0.5 animations:^{
[yourView layoutIfNeeded];
}];
【讨论】: