Reputation: 2127
I am working a pictureView which needs to be zoom in and zoom out on tap, I have searched for the proper zoom in and zoom out, but not found (I have tried to achieve same task with UIView but its not good), so i came to ask if any body can help ?
I have 4 images assembled in a tableview, 2 in a row. What i want is if user taps an image, it just zoom in and if he taps again it should zoom out. Following is the code sample i have tried so far
[UIView animateWithDuration:1.0f animations:^{
img.frame = CGRectMake(0, 0, 300, 300);
img.alpha = 1.0;
}];
but when ever i try to use that, instead of zooming in, it translates from one of the 4 diagonals :( I hope I have cleared this question as possible as I can.
Regards
Upvotes: 0
Views: 1387
Reputation: 11768
UIImageView
you are adding to the cells.UIImageView
to show when user taps the image.
Here is what you do on tap:
2.1 Assign image to your hidden UIImageView
, set its alpha to 0.0 and make it not hidden
2.2 Set proper frame to the hidden image view.
2.3 animate the reveal of the image like [UIView animateWithDuration:1.0f animations:^{ img.frame = CGRectMake(0, 0, 300, 300); img.alpha = 1.0; }];
2.4 add tap gesture recognizer to your hidden image view in order to dismiss it when user taps. 2.5 make reverse animation when user taps e.g. set alpha of displayed image view to 0.0 in uiview animation block.
I didn't provide the code for the whole thing assuming that you will learn and remember such things. Good Luck!
EDIT: don't forget to add hidden uiimageview to your view.
Upvotes: 1