Devesh
Devesh

Reputation:

UIImageView Zoom in and out

I want to change the images depending upon the zoom in or zoom out. Means if i am zoom upto certain limit then it should show other image.

I added one UIImageView in UIScrollView and zoom in and out functionality is working but i am not getting how to change image during zoom in and zoom out.

And while changing image it should have fade effect in between.

Can any one help me for this?

Upvotes: 2

Views: 4635

Answers (2)

David Kanarek
David Kanarek

Reputation: 12613

UIScrollViewDelegate has a method - (void)scrollViewDidEndZooming:(UIScrollView *)scrollView withView:(UIView *)view atScale:(float)scale.

In this method you can check the scale and update the UIImageView with the appropriate UIImage.

Upvotes: 4

Marco Mustapic
Marco Mustapic

Reputation: 3859

For animating an image change, you can do:

[UIView beginAnimations:@"imageChange" context:NULL];
yourImageView.image = yourNewImage;
[UIView commitAnimations];

The change will have the fade effect you want.

About the zoom-in and zoom-out functionality I'm not sure, but you should check if the view is zooming (zooming property for your UIScrollView should be true) and then use the zoomScale property. I suppose you could do this with a timer, continuously checking if the view is zooming.

Upvotes: 0

Related Questions