2011-03-28 171 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

相关问题