2012-07-20 196 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

希望它有幫助!