-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch* touch = [touches anyObject];
UIImageView* imageView = (UIImageView*)[self.view viewWithTag:1000];
if ([touches count] == 1) {
CGPoint nowTouch = [touch locationInView:self.view];
CGPoint lastTouch = [touch previousLocationInView:self.view];
float xDif = nowTouch.x - lastTouch.x;
float yDif = nowTouch.y - lastTouch.y;
CGAffineTransform translate = CGAffineTransformMakeTranslation(xDif, yDif);
if (CGRectContainsPoint(imageView.frame, nowTouch)) {
[imageView setTransform:CGAffineTransformConcat([imageView transform], translate)];
}
// [self setTransform: CGAffineTransformConcat([self transform], translate)];
}
}
图片移动
最新推荐文章于 2021-06-30 07:12:25 发布