首先UIImageView
使用您的视图中心属性设置您的中心,如下所示..
yourImageView.center = self.view.center;
GestureRecognizer
如下设置后..
UIRotationGestureRecognizer *rotationRecognizer = [[UIRotationGestureRecognizer alloc] initWithTarget:self action:@selector(rotate:)];
[rotationRecognizer setDelegate:self];
[yourImageView addGestureRecognizer:rotationRecognizer];
[rotationRecognizer release];
然后使用这种波纹管方法进行旋转UIImageView
-(void)rotate:(id)sender
{
UIView *imgTempGest = [sender view];
if([(UIRotationGestureRecognizer*)sender state] == UIGestureRecognizerStateEnded)
{
lastRotation = 0.0;
return;
}
CGFloat rotation = 0.0 - (lastRotation - [(UIRotationGestureRecognizer*)sender rotation]);
CGAffineTransform currentTransform = [(UIPinchGestureRecognizer*)sender view].transform;
CGAffineTransform newTransform = CGAffineTransformRotate(currentTransform,rotation);
[[(UIRotationGestureRecognizer*)sender view] setTransform:newTransform];
[imgTempGest setTransform:newTransform];
lastRotation = [(UIRotationGestureRecognizer*)sender rotation];
}
像下面这样lastRotation
的变量CGFloat
..
CGFloat lastRotation;