UIButton高亮动画 [英] UIButton highlight animation

查看:93
本文介绍了UIButton高亮动画的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

触摸后,还有什么方法可以使按钮高亮显示0.1秒?我将setImage用于stateHighlighted,但是如果我快速按下它,按钮会闪烁。

Is there any way to highlight button for 0.1 sec more after touching? I'm using setImage for stateHighlighted, but my button blinks if I press it very fast.

还有另外一件事。在iOS 7中,电话屏幕(带有数字)使用了非常有趣的动画。高亮显示的按钮逐渐褪色,然后返回正常状态。也许有人知道,如何实现它?

And one more thing. In iOS 7 at the phone screen (with numbers) used very interesting animation. Highlighted button is slowly fading and then returns to normal state. Maybe somebody know, how to realise it?

推荐答案

您可以为UIButton的ALPHA属性设置动画

You can animate ALPHA property of your UIButton

[UIView animateWithDuration:0.25 animations:^{
    yourButton.alpha = 0.0;
} completion:^(BOOL finished) {
    [UIView animateWithDuration:0.25 animations:^{
        yourButton.alpha = 1.0;
    } completion:nil];
}];

这将使您的按钮在0.25秒的时间内消失。将Alpha设置为1.0,以使其再次淡入。

This will fade your button out over a 0.25 second period. Set the alpha to 1.0 to fade it back in again.

这篇关于UIButton高亮动画的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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