这段代码是实现缩放, 开始我以为只要创建四个手指就可以.后来崩了.原因是赋值出现问题
最后发现要创建一个数组将所有元素加进来.然后从数组中取出四个手指
// 一开始这一段是没有的
// NSArray *array = [touches allObjects];
//
// CGPoint prePoint1 = [[array objectAtIndex:0] previousLocationInView:self];
// CGPoint prePoint2 = [[array objectAtIndex:1] previousLocationInView:self];
//
// CGPoint Point1 = [[array objectAtIndex:0] locationInView:self];
// CGPoint Point2 = [[array objectAtIndex:1] locationInView:self];
UITouch *previousTouch1 = [touches anyObject];
CGPoint prePoint1 = [previousTouch1 previousLocationInView:self];
UITouch *previousTouch2 = [touches anyObject];
CGPoint prePoint2 = [previousTouch2 previousLocationInView:self];
UITouch *Touch1 = [touches anyObject];
CGPoint point1 = [Touch1 locationInView:self];
UITouch *Touch2 = [touches anyObject];
CGPoint point2 = [Touch2 locationInView:self];
CGFloat x = sqrt((prePoint1.x - prePoint2.x)*(prePoint1.x - prePoint2.x) + (prePoint1.y - prePoint2.y)*(prePoint1.y - prePoint2.y)) ;
CGFloat y = sqrt((point1.x - point2.x)*(point1.x - point2.x) + (point1.y - point2.y)*(point1.y - point2.y)) ;
self.bounds = CGRectMake(0,0,(self.frame.size.width*y/x),(self.frame.size.height*y/x));