I did it, this is my final code:
if([gesture state] == UIGestureRecognizerStateBegan) {
previousScale = 1.0;
lastPoint = [gesture locationInView:[gesture view]];
}
if (
[gesture state] == UIGestureRecognizerStateChanged) {
CGFloat currentScale = [[[gesture view].layer valueForKeyPath:@"transform.scale"] floatValue];
// Constants to adjust the max/min values of zoom
const CGFloat kMaxScale = 4.0;
const CGFloat kMinScale = 1.0;
CGFloat newScale = 1 - (previousScale - [gesture scale]); // new scale is in the range (0-1)
newScale = MIN(newScale, kMaxScale / currentScale);
newScale = MAX(newScale, kMinScale / currentScale);
scale = newScale;
CGAffineTransform transform = CGAffineTransformScale([[gesture view] transform], newScale, newScale);
[gesture view].transform = transform;
CGPoint point = [gesture locationInView:[gesture view]];
CGAffineTransform transformTranslate = CGAffineTransformTranslate([[gesture view] transform], point.x-lastPoint.x, point.y-lastPoint.y);
[gesture view].transform = transformTranslate;
}