I am trying to figure out how to achieve this. I want to have a view centred on the screen that can be pinched for zoom in and zoom out but also be panned across the screen. One way I thought of trying to replicate this was to have a UIView within UIScrollView. Let's say the UIView is just a black square. The UIView will be the same size as the UIScrollView and always remain centred. When I pinch the UIView to zoom out, as it gets smaller and the UIScrollView will zoom in at the same rate. This allows space to pan. The UIView would of shrunk, remained centred and the UIScrollView's content area increased. Is this something that is possible? Is using a UIScrollView the wrong way to go about it?
Asked
Active
Viewed 70 times
0
-
This is possible. Disable `userInteractionEnabled` on one of your `UIScrollView`s, attach a delegate to the other and invert the zoom factor when you receive zoom events. – Ian MacDonald Jan 29 '15 at 14:48
-
You only need one UIScrollView. I have a class that does just this, except it uses a UIImageView (which inherits from UIView) as the contained view as the intent was to scale and pan an image. If you think this might work for you, let me know and I'll tweak and upload it for you. – MDB983 Jan 29 '15 at 16:31
-
hey, yes that is exactly what I want to do. would I be able to take a look please? – Kex Jan 29 '15 at 16:44