Search code examples
iosquartz-2dgestures

Is it possible to use pinch to zoom Using Quartz 2D (CGrect)?


UIWebview allows pinch to zoom, but is it possible to use this gesture when using CGRect using Quartz 2d? and if so how?: All help is appreciated.


Solution

  • Yes it is possible. You should be using UIPinchGestureRecognizer in conjunction with functions to manipulate CGAffineTransform properties of objects. Using UIPinchGestureRecognizer you can get zoom scale and apply a CGAffineTransform to CGRect. Following links should help you in doing so.
    UIPinchGestureRecognizer for zooming http://www.raywenderlich.com/6567/uigesturerecognizer-tutorial-in-ios-5-pinches-pans-and-more
    For applying affine transform to CGRect, look into CGRectApplyAffineTransform method on https://developer.apple.com/library/mac/#documentation/graphicsimaging/reference/CGAffineTransform/Reference/reference.html this reference page.