闪烁隐藏并使用块 [英] Blink hidden and using blocks

查看:106
本文介绍了闪烁隐藏并使用块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有方法:

- (void)blinkView:(UIView *)view
{
    view.layer.opacity = 0.0f;
    view.hidden = NO;

    [UIView beginAnimations:@"Blinking" context:nil];
    [UIView setAnimationRepeatCount:1.0];
    [UIView setAnimationDuration:0.6f];
    [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
    view.layer.opacity = 1.0f;
    [UIView commitAnimations];
}

我该如何用块编写此代码,以及如何必须实现具有反作用的方法(用眨眼隐藏uiview)?

How can i write this code with blocks, and how i must implement method with reverse effect (hide uiview with blink) ?

推荐答案

[UIView transitionWithView: view
       duration:0.6f
       options:UIViewAnimationOptionCurveEaseInOut
       animations:^{ view.layer.opacity = 1.0f; }
       completion:NULL];

[UIView transitionWithView: view
       duration:0.6f
       options:UIViewAnimationOptionCurveEaseInOut | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse
       animations:^{ view.layer.opacity = 1.0f; }
       completion:NULL];

您可以通过递归调用动画块来设置重复计数(请参见此处).

You can set the repeat count by recursively calling the animation block (see here).

希望它会对您有所帮助.

Hope it will help you.

这篇关于闪烁隐藏并使用块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆