我需要在 iPad 应用程序中旋转图像(例如顺时针)。图像保存在视图中:
UIImageView *view1 = [[UIImageView alloc] initWithFrame:CGRectMake(startX+lineWidth, startY+lineHeight, lineWidth, lineHeight)];
view1.tag = 0;
view1.image = [UIImage imageNamed:[images objectAtIndex:0]];
在
- (void)touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
我正在这样做:
CGPoint d1 = [touch locationInView:touch.view];
CGPoint d2 = [touch previousLocationInView:touch.view];
CGFloat angle1 = atan2(d1.y, d1.x);
CGFloat angle2 = atan2(d2.y, d2.x);
subview.transform = CGAffineTransformRotate(subview.transform, angle2-angle1);
视图正在旋转,但它与触摸(或我的开发环境中的光标)一起运行并不顺畅。相反,它在触摸之前浮动一点。
我错过了什么?