ios - UIImageView 闪烁动画

标签 ios objective-c uiimageview viewdidload

我正在尝试让 UIImageViewviewDidLoad 上闪烁。我不确定最好的方法是什么。我试过使用 .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/

相关文章:

ios - Phonegap 插件 - 将行附加到应用程序委托(delegate)

Objective-C 变量声明困惑

ios - 澄清 Objective-C 协议(protocol)和授权

ios - 滚动 UITableView 时 UIImageViews 变黑

ios - 尝试使用 UIPickerView 选择要在 UIImageView 中显示的图像

iOS swift : How to properly scale down an image?

ios - 在 RxSwift 中处理嵌套的可观察对象

ios - 如何从UISlider 的自定义位置播放音频?

ios - QuickDialog - 如何选择 QSelectItemElement=

objective-c - 使用 UIDocumentPickerViewController initForOpeningContentTypes 时无法选择文件