【发布时间】:2015-09-22 08:04:08
【问题描述】:
我有一个 UIScrollView 放置在一个 ViewController 内,我已经给了 AutoLayout Constraints 并且所有这些都满意。 scrollView 包含大约 20 个 UIButton 子视图。我也给了他们自动布局约束,他们也都很满意。
我需要做的是在视图首次启动时为这些按钮设置动画。这是我的动画代码
for (UIButton *button in [scrollView subviews]) {
CGRect mainFrame = [button frame];
[UIView animateWithDuration:0.0 animations:^{
button.frame = CGRectMake(button.center.x, button.center.y, 0, 0);
} completion:^(BOOL finished) {
[UIView animateWithDuration:1 delay:0.5 usingSpringWithDamping:0.3 initialSpringVelocity:0.2 options:UIViewAnimationOptionCurveEaseOut animations:^{
button.frame = mainFrame;
} completion:^(BOOL finished) {
}];
}];
}
当我使用这段代码时,子视图没有动画。 但是当我设置
[button setTranslatesAutoresizingMaskIntoConstraints:YES];
它有效。但是这次我得到了错误 Unable to Simultaneously Satisfy constraints。
有没有其他方法可以做到这一点,还是我应该忽略错误消息并继续执行?
【问题讨论】:
标签: ios objective-c animation uiscrollview autolayout