我使用animationWithDuration
来为元素添加动画。我在另一个动画的 completion
block 中插入了 1 个动画。
[UIView animateWithDuration:2.0 delay:0.1 options:UIViewAnimationOptionCurveEaseInOut animations:^{
} completion:^(BOOL finished) {
[UIView animateWithDuration:2.0 delay:0.1 options:UIViewAnimationOptionCurveEaseInOut animations:^{
} completion:^(BOOL finished) {
... //and simple
}];
}];
所以我有六到九个 animationWithDuration
block 元素的楼梯。那么我如何优化它?
抱歉我的英语不好。
最佳答案
如果您有许多嵌套动画,代码很快就会变得非常难以阅读。 因此,这里的方法可能是保存所有动画 block 的数组并迭代它们而不嵌套它们。
这里显示了一个可能的代码示例: Multiple UIView Animations Without Nested Blocks
关于ios - 动画的楼梯animationWithDuration,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19087211/