我有一个路径存储在一个CGPoints数组中,我想移动一个图像.这是我到目前为止的一般代码:
-(void)movePic:(id)sender{
for(int i = 0; i < self.array.count; i++){
CGPoint location = [[self.array objectAtIndex:i] CGPointValue];
[UIView animateWithDuration:0.1 animations:^{
self.imageView.center = location;
} completion:^(BOOL finished){
}];
}
}
Run Code Online (Sandbox Code Playgroud)
问题是for循环运行得非常快,所以你只能在最后几点看到动画.我不确定如何更好地设计这个.理想情况下,我可以做些什么来确保一个动画在另一个动画开始之前完成?我不应该使用for循环吗?谢谢