我想让UI
ImageView闪光几次.
目前我不知道该怎么做
实际代码:
-(void)arrowsAnimate{ [UIView animateWithDuration:1.0 animations:^{ arrow1.alpha = 1.0; arrow2.alpha = 1.0; arrow3.alpha = 1.0; NSLog(@"alpha 1"); } completion:^(BOOL finished){ [self arrowsAnimate2]; }]; } -(void)arrowsAnimate2{ [UIView animateWithDuration:1.0 animations:^{ arrow1.alpha = 0.0; arrow2.alpha = 0.0; arrow3.alpha = 0.0; NSLog(@"alpha 0"); } completion:^(BOOL finished){;}]; }
后来我就这样称呼:
for (int i = 0;i < 10; i++){ [self arrowsAnimate]; }
这给我10x alpha 1,然后是10x alpha 0.在中间我们只看到一个动画.
有什么建议么?
谢谢.
解决方法
有一个更简单的方法来实现一个闪烁的动画只使用1个动画块:
aview.alpha = 1.0f; [UIView animateWithDuration:0.5f delay:0.0f options:UIViewAnimationOptionAutoreverse animations:^ { [UIView setAnimationRepeatCount:10.0f/2.0f]; aview.alpha = 0.0f; } completion:^(BOOL finished) { [aview removeFromSuperview]; }];
诀窍是使用[UIView setAnimationRepeatCount:NTIMES / 2]; * _inside_ *你的动画块.不需要额外的功能或额外的循环.