如何使用动画缩放视图

时间:2012-06-06 12:13:44

标签: iphone objective-c ipad

当事件发生时,我使用下面的代码来扩展我的视图。但是我希望通过动画放大或缩小视图而不是直接看到缩放的结果。我怎样才能达到这个效果?

view.transform = CGAffineTransformMakeScale(scaleFactor, scaleFactor) 

2 个答案:

答案 0 :(得分:3)

您可以使用UIViewAnimations

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.5];
[UIView setAnimationDelay:1.0];
[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

view.transform = CGAffineTransformMakeScale(scaleFactor, scaleFactor); 

[UIView commitAnimations];

答案 1 :(得分:3)

您也可以使用块动画。

[UIView animateWithDuration:0.3 animations:^{
    view.transform = CGAffineTransformMakeScale(scaleFactor, scaleFactor) 
}];