How to fade away in UIButton

How can I fade into UIButton in a view?

now i am adding it with:

    [myView addSubview:myButton];

but if I want to quench it?

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

Thank!

+3
source share
2 answers

Try using

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

before calling the animation.

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

If you shade it and add it for viewing, then the fading in the part will not be within sight (it will be behind the scenes). So first add it to zero alpha, and then put it out.

+9
source

You must first add a subtitle view, as you did with

 [myView addsubview:myButton];

Give it alpha 0.0 when you add it to your view. After that, you should animate your button to an alpha value of 1.0

+1
source

All Articles