0

我有一个我正在尝试制作动画的 UIView。

[UIView beginAnimations:@"scaleAnimation" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
[UIView setAnimationDuration:0.5];

CGRect f = self.frame;
f.size.width = f.size.width * 2;
f.size.height = f.size.height * 2;
self.frame = f;

[UIView commitAnimations];

动画效果很好,但无论如何我可以让动画沿着中心缩放吗?
现在,看起来该点位于左上角。

使用 CGAffineTransform 比例 = CGAffineTransformMakeScale(2.0, 2.0); 沿着中心做动画,但是做一个触摸事件,当我试图检测 UIView 的透明区域时,这些点似乎都搞砸了。

谢谢你,
三通

4

1 回答 1

2

这很简单。bounds改为动画。正如文档所说:

更改边界大小会相对于其中心点增大或缩小视图。

所以你的代码会是这样的

[UIView beginAnimations:@"scaleAnimation" context:nil];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut]; 
[UIView setAnimationDuration:1.5];

CGRect f = myView.bounds;
f.size.width = f.size.width * 2;
f.size.height = f.size.height * 2;
myView.bounds = f;

[UIView commitAnimations];
于 2012-05-22T22:14:56.697 回答