UIScrollView缩放动画

时间:2009-12-23 22:16:44

标签: iphone

我使用CGAffineTransformScaleMake创建了一个缩放动画,

[UIView beginAnimations:nil context:view];
[UIView setAnimationDuration: 0.4f];
[UIView setAnimationDelegate: self];

view.transform =  CGAffineTransformMakeScale(scale, scale);

CGSize zoomViewSize   = viewForZooming.frame.size;
view.frame = CGRectMake(0, 0, zoomViewSize.width, zoomViewSize.height);
scrollView.contentSize = zoomViewSize;
scrollView.contentOffset = centerPoint;
[UIView commitAnimations];

但每次我缩小时,我的内容视图都会跳转到视图的最左侧部分。如何在缩小时使视图保持其位置?

感谢。

1 个答案:

答案 0 :(得分:3)

您不应尝试手动设置UIScrollView的转换;相反,使用zoomScale属性或-zoomToRect:animated:方法。

相关问题