domlao
domlao

Reputation: 16029

UIScrollView zoom animation

I crated a zoom animation using 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];

But everytime I zoom out, my content view will just jump to the left most part of the view. How can I make the view stay its position when zooming out?

Thanks.

Upvotes: 0

Views: 1544

Answers (1)

Ben Gottlieb
Ben Gottlieb

Reputation: 85542

You should not try and set the transform of a UIScrollView manually; instead, use the zoomScale property, or the -zoomToRect:animated: method.

Upvotes: 3

Related Questions