Fre*_*XxX 9 objective-c uiview ipad
我想UIImageView
多次闪光.
目前我不知道该怎么做.
-(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){;}];
}
Run Code Online (Sandbox Code Playgroud)
后来我称之为:
for (int i = 0;i < 10; i++){
[self arrowsAnimate]; }
Run Code Online (Sandbox Code Playgroud)
这给了我10x alpha 1,然后是10x alpha 0.在中间我们只看到一个动画.有什么建议?
谢谢.
Dad*_*ado 20
有一种更简单的方法可以仅使用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];
}];
Run Code Online (Sandbox Code Playgroud)
诀窍是使用[UIView setAnimationRepeatCount:NTIMES/2]; *_inside_* your animation block
.无需额外功能或额外循环.
归档时间: |
|
查看次数: |
5766 次 |
最近记录: |