图片跟随双指捏合的距离放大或者缩小。

 


利用-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event  实现。

touchesMoved每当手指在屏幕上移动的时候都会运行。

 


1.检测手指的个数

NSArray * touchesArr=[[event allTouches] allObjects];
NSLog(@"手指个数%d",[touchesArr count]);

 


2.检测两指的坐标,从而计算两指的距离。

    p1=[[touchesArr objectAtIndex:0] locationInView:self.view];
    p2=[[touchesArr objectAtIndex:1] locationInView:self.view];

 


3.计算距离增加,则增大图片,距离减小则缩小图片。用imageview的frame来控制图片的大小。


 imageView.frame=CGRectMake(imgFrame.origin.x-addwidth/2.0f, imgFrame.origin.y-addheight/2.0f, imgFrame.size.width, imgFrame.size.height);

相关文章:

  • 2021-12-30
  • 2022-12-23
  • 2021-07-08
  • 2022-12-23
  • 2021-07-03
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2022-01-16
相关资源
相似解决方案