UIImageView闪烁动画

Owe*_*wen 4 objective-c uiimageview viewdidload ios

我试图UIImageView眨眼viewDidLoad.我不确定最好的办法是什么.我已经使用循环与尝试.hidden=YES.hidden=NO,但是这似乎是一个不错的方法来做到这一点.我需要一些适当的建议.

m.e*_*iry 5

试试这个 :

-(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];

        }];


    }];
}
Run Code Online (Sandbox Code Playgroud)

或者如果你想让它永远眨眼试试这个:

-(void)blinkForever:(UIView*)view
{
    [UIView animateWithDuration:0.2 delay:0.0 options:UIViewAnimationOptionAutoreverse|UIViewAnimationOptionRepeat animations:^{

        view.alpha = 0.0;

    } completion:nil];
}
Run Code Online (Sandbox Code Playgroud)