我想在iPad上刷一个UIImageview,我该怎么做? [英] I want to flash an UIImageview on the iPad, how do I do that?
本文介绍了我想在iPad上刷一个UIImageview,我该怎么做?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想让 UIImageView
闪过几次。
目前我不知道该怎么做。
Currently I don't know how to do that.
-(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.中间我们只看到一个动画。
有什么建议吗?
This gives me 10x alpha 1, and then 10x alpha 0. In the middle we see only one animation. Any suggestions?
谢谢。
推荐答案
那里是一种使用1个动画块实现闪动动画的简单方法:
There is a simpler way to achieve a flashing animation using only 1 animation block:
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_ *您的动画块
。
无需额外功能或额外循环。
The trick is to use [UIView setAnimationRepeatCount:NTIMES/2]; *_inside_* your animation block
.
No need for extra functions or extra loops.
这篇关于我想在iPad上刷一个UIImageview,我该怎么做?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文