0

I use the code in follow to do the scaling

 CGAffineTransform currentTransform = self.imageView.transform;
 CGAffineTransform newTransform = CGAffineTransformScale(currentTransform, sl, sl);
 [self.imageView setTransform:newTransform];

,but i found it scales around the image center,is there any methods that i can use to make it scales around my touch center?

AFu
  • 73
  • 6
  • I add the following codes to set the anchorPoint to archive this,but it works not so accurate. – AFu Jan 20 '16 at 08:47
  • CGPoint p1 = [sender locationOfTouch: 0 inView:self.imageView]; CGPoint p2 = [sender locationOfTouch: 1 inView:self.imageView]; CGPoint newCenter = CGPointMake( (p1.x+p2.x)/2,(p1.y+p2.y)/2); [self setAnchorPoint:CGPointMake(newCenter.x/self.imageView.bounds.size.width, newCenter.y/self.imageView.bounds.size.height) forView:self.imageView]; – AFu Jan 20 '16 at 08:47
  • - (void)setAnchorPoint:(CGPoint)anchorPoint forView:(UIView *)view { CGPoint oldOrigin = view.frame.origin; view.layer.anchorPoint = anchorPoint; CGPoint newOrigin = view.frame.origin; CGPoint transition; transition.x = newOrigin.x - oldOrigin.x; transition.y = newOrigin.y - oldOrigin.y; view.center = CGPointMake (view.center.x - transition.x, view.center.y - transition.y); } – AFu Jan 20 '16 at 08:47

0 Answers0