在我的应用程序中,从滚动视图拖放图像视图。放下后,当用户触摸我放下的东西时,我想分别旋转图像。在这里,我只能旋转最后拖动的图像。我无法旋转以前拖动的图像。我在移动到旋转的触摸中使用此代码
[myview setTransform:CGAffineTransformRotate([myview transform], angleInRadians)];
在我的应用程序中,从滚动视图拖放图像视图。放下后,当用户触摸我放下的东西时,我想分别旋转图像。在这里,我只能旋转最后拖动的图像。我无法旋转以前拖动的图像。我在移动到旋转的触摸中使用此代码
[myview setTransform:CGAffineTransformRotate([myview transform], angleInRadians)];
你可以使用 UIRotationGestureRecognizer
UIRotationGestureRecognizer *rotationGesture = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotatePiece:)];
rotationGesture.delegate=self;
[YourImageview addGestureRecognizer:rotationGesture];
- (void)rotatePiece:(UIRotationGestureRecognizer *)gestureRecognizer
{
[self adjustAnchorPointForGestureRecognizer:gestureRecognizer];
if ([gestureRecognizer state] == UIGestureRecognizerStateBegan || [gestureRecognizer state] == UIGestureRecognizerStateChanged) {
[gestureRecognizer view].transform = CGAffineTransformRotate([[gestureRecognizer view] transform], [gestureRecognizer rotation]);
[gestureRecognizer setRotation:0];
}
}