2012-07-20 138 views
1

隐藏或显示视图中的一个按钮,我使用隐藏和动画显示按钮,iphone

myButton.hide = YES or myButton.hide = NO 

我正在寻找的方式来显示一个按钮起劲如

慢慢淡出有谁知道如何做到这一点,请帮助

感谢

回答

4

可以使用UIView动画。 下面是简单的实现:

// to hide 
[UIView animateWithDuration:0.5 
    delay:1.0 
    options: UIViewAnimationCurveEaseOut 
    animations:^{ 
     myButton.alpha = 0.0 
    } 
    completion:^(BOOL finished){ 
     NSLog(@"Done!"); 
    }]; 

// to show (implement in another method) 
[UIView animateWithDuration:0.5 
    delay:1.0 
    options: UIViewAnimationCurveEaseOut 
    animations:^{ 
     myButton.alpha = 1.0; 
    } 
    completion:^(BOOL finished){ 
     NSLog(@"Done!"); 
    }]; 

这里是一个很好的教程:How To Use UIView Animation Tutorial

你可能想看看文档太:UIView Class Reference

也有类似的QA在这网站:例如How can I animate a UIButton Alpha property

希望它有帮助!