我是iPhone开发的新手。我正在使用UIImageView
来为阵列中的图像设置动画。我决定通过一个名为isAnimating
的属性停止动画。但它总是回归真实。
我想检查动画是否已完成,或者还有一些持续时间来完成动画。
请告诉我如何检查。
生成属性BOOL IsAnimating然后做这个代码
{
[UIView beginAnimations:@"Animation of ImageVIew Begins" context:nil];
IsAnimating =YES;
[UIView setAnimationDuration:0.4]; //you can put your time
NSLog(@" Animating");
[UIView setAnimationDelegate:self];
[UIView setAnimationDidStopSelector:@selector(AnimationComplete)];
// Your animation code here
[UIView commitAnimations];
}
- (void) AnimationComplete
{
isAnimating = NO;
}
在动画完成之前,BOOl变量将为YES。。则它将变为无
根据持续时间使用委托来触发接收器上需要的任何方法。
您应该在动画块内制作动画:
[UIView animateWithDuration:duration animations:^{
//animation code here
} completion:^(BOOL finished)
{
//this will be called when the animation is finished
}];
编辑:这个答案是错误的,可能不应该被接受,对于任何来这里寻找正确答案的人来说:这个答案回答了这个问题,我认为