Skip to content

Instantly share code, notes, and snippets.

@aitskovi
aitskovi / GestureImage.m
Created March 4, 2011 05:03
A pannable, rotatable and zoomable image with gesture recognizers.
- (id)initWithImage:(UIImage *)image {
if ((self = [super initWithImage:image])) {
self.userInteractionEnabled = YES;
self.multipleTouchEnabled = YES;
_pinchGestureRecognizer = [[UIPinchGestureRecognizer alloc] initWithTarget:self action:@selector(pinchRecognized:)];
[self addGestureRecognizer:_pinchGestureRecognizer];
_pinchGestureRecognizer.delegate = self;
_panRecognizer = [[UIPanGestureRecognizer alloc] initWithTarget:self action:@selector(panRecognized:)];
[self addGestureRecognizer:_panRecognizer];
_panRecognizer.delegate = self;