如何淡入的UIButton [英] How Fade in UIButton

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

问题描述

我怎么能在一个UIButton淡入视图?

how can I fade in a UIButton in a view?

现在我添加:

    [myView addSubview:myButton];

但如果我要淡出呢?

but if I want to fade it?

[UIView animateWithDuration:3.0
delay:0.0
options: UIViewAnimationCurveEaseInOut
animations:^{myButton.alpha = 1.0}
completion:^(BOOL finished){ [myView addSubview:myButton]; }];

谢谢!

推荐答案

尝试使用

myButton.alpha = 0.0;
[myView addSubview:myButton];

之前的动画调用。

prior to the animation call.

[UIView animateWithDuration:3.0
                      delay:0.0
                    options: UIViewAnimationCurveEaseInOut
                 animations:^{myButton.alpha = 1.0;}
                 completion:nil];

如果您褪色它在和添加,以查看,部分衰落不会视图的边界内(将屏幕外)。因此,首先将其添加在零阿尔法,然后消失它

If you fade it in and add to view, the fading in part will not be within the bounds of the view (will be offscreen). So add it first at zero alpha and then fade it in.

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

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