我正在尝试让 UIImageView
在 viewDidLoad
上闪烁。我不确定最好的方法是什么。我试过使用 .hidden=YES
和 .hidden=NO
的循环,但这似乎是一种不好的方法。我需要一些适当的建议。
最佳答案
试试这个:
-(void)blink:(UIView*)view count:(int) count
{
if(count == 0)
{
return;
}
[UIView animateWithDuration:0.2 animations:^{
view.alpha = 0.0;
} completion:^(BOOL finished){
[UIView animateWithDuration:0.2 animations:^{
view.alpha = 1.0;
} completion:^(BOOL finished){
[self blink:view count:count-1];
}];
}];
}
或者如果你想让它永远闪烁试试这个:
-(void)blinkForever:(UIView*)view
{
[UIView animateWithDuration:0.2 delay:0.0 options:UIViewAnimationOptionAutoreverse|UIViewAnimationOptionRepeat animations:^{
view.alpha = 0.0;
} completion:nil];
}
关于ios - UIImageView 闪烁动画,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32026869/