2011-03-28 174 views
0

我在Jamie Oliver應用程序中注意到,當您單擊其中一個按鈕時,它會在平滑過渡中從一種尺寸變爲另一種尺寸。有誰知道這是如何完成的?我嘗試過使用一些UIView動畫,但沒有一個滿足我的需求。將UIButton從一個圖像動畫到另一個圖像

回答

0

UIAnimations本身不能給你那種效果。你需要將它們與變換結合起來以達到你所說的效果。嘗試以下方法。你會得到你所需要的...

[UIView beginAnimations:@"Zoomin" context:nil]; 

[UIView setAnimationDuration:0.25]; 
starImage.transform=CGAffineTransformMakeScale(2.5, 2.5); 
[UIView commitAnimations]; 
[UIView beginAnimations:@"Zoomout" context:nil]; 
[UIView setAnimationDuration:0.25]; 
starImage.transform=CGAffineTransformMakeScale(1, 1); 
[UIView commitAnimations]; 
+0

非常感謝,它效果很棒! – Magnus 2011-03-28 13:31:42

+0

順便說一句,你知道如何在動畫運行的時候真正改變按鈕的圖像嗎? – Magnus 2011-03-28 13:33:23

+0

你需要插入這段代碼我的動畫塊... \t [button setImage:[UIImage imageNamed:@「yourImage」] forState:UIControlStateNormal]; – 2011-03-28 14:06:39

相關問題