-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event{
if ([touches count] == 1) {
return;
}
NSArray *touchesArr = [touches allObjects];
UITouch *firstTouch = [touchesArr firstObject];
UITouch *secondTouch = [touchesArr lastObject];
CGPoint previousPoint1 = [firstTouch previousLocationInView:self];
CGPoint previousPoint2 = [secondTouch previousLocationInView:self];
CGPoint currentPoint1 = [firstTouch locationInView:self];
CGPoint currentPoint2 = [secondTouch locationInView:self];
CGFloat previousDistance = [self distanceOfPoint1:previousPoint1 point2:previousPoint2];
CGFloat currentDistance = [self distanceOfPoint1:currentPoint1 point2:currentPoint2];
CGFloat scale = currentDistance / previousDistance;
self.bounds = CGRectMake(0, 0, self.bounds.size.width * scale, self.bounds.size.height *scale);
}
-(CGFloat)distanceOfPoint1:(CGPoint)point1 point2:(CGPoint)point2{
CGFloat dx = point1.x - point2.x;
CGFloat dy = point1.y - point2.y;
return sqrt(pow(dx, 2) + pow(dy, 2));
}