Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to do iPad Photos app pinch to expand

I don't think this has been asked before on this site, but I might be wrong.

Does anyone know the basics of how to get that whole effect with the iPad Photos app? Basically, pinching a stack of photos lets you have a "peek" at the photos in that stack, which expands based on the distance between your 2 fingers in the pinch, then fully completing the outwards pinch gesture opens the photos in the stack in a new view.

See this video to get what I mean. I know of at least one third party app that uses the same method as the iPad Photo app, so I know it's possible to do. I'm guessing I would do something with UIPinchGestureRecognizer but I'm not sure exactly how to proceed.

like image 275
indragie Avatar asked Jun 13 '10 16:06

indragie


1 Answers

Well there's no especially easy way to do it except the obvious way:

Use a UIPinchGestureRecognizer on the individual thing that can be expanded. Give it a target and action, and it'll basically call that method a million times while your fingers are pinching (more specifically everytime your fingers move in or move out).

Within the method, check the scale property, which is basically how much your fingers have moved in or moved out. Layout the appropriate views within the rectangle based on the scale, and so on and so forth. You probably have a general idea on how it should be done in the first place, and really that's how it's done.

However, I should warn you, Apple has rejected apps based on pinch-to-expand before. I'm not sure if it's still in effect, but here's an article about it: http://www.appleinsider.com/articles/10/04/07/apple_rejected_ipad_app_for_using_pinch_to_expand_gesture.html

like image 90
David Liu Avatar answered Sep 29 '22 06:09

David Liu