點擊iPhone按鈕時是否可以製作自定義動畫?我喜歡App Store按鈕這樣的東西 - 它顯示價格,然後當你點擊它時,它會改變顏色和文本更改爲現在購買,然後當你再次點擊它時,它完成購買。iPhone - 如何按下時按動畫按鈕?
UIViewAnimationTransition只包含一些不提供完整功能的值。是否有可能做這樣的事情,但與動畫:
- (IBAction) changeButtonDisplay:(id)sender {
[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.8];
[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:purchaseButton cache:NO]; //the built in UIViewAnimationTransition values don't provide enough flexibility
[purchaseButton setTitle:@"Buy Now" forState:UIControlStateNormal];
[purchaseButton setBackgroundColor:[UIColor greenColor]];
[purchaseButton addTarget:self action:@selector(purchaseItems:) forControlEvents:UIControlEventTouchUpInside];
[UIView commitAnimations];
}
此代碼的工作,並會顯示正確的過渡,並允許第二次點擊做適當的行動,但瞬間的標題和顏色的變化,而不是在流暢的動畫中。是否有可能輕鬆地做這樣的動畫,我是否必須創建一個UIButton子類並動畫「手動」?如果是這樣,我需要重寫什麼方法?
此外,默認的動畫過渡是一個褪色,所以你可能不會需要設置的動畫過渡。 – Jasarien 2009-06-22 23:08:59