0

我已经为UIImageView.

这是我实现的代码:

- (IBAction)rotaehandler:(UIRotationGestureRecognizer *)sender
{
    sender.view.transform = CGAffineTransformRotate(sender.view.transform, sender.rotation);
}

我连接UIRotationGestureRecognizerUIImageView. 它可以工作,但是,我怎样才能从它的中心旋转图像。

4

2 回答 2

1
CGFloat initialRotation = atan2f(sender.view.transform.b-somefloat, sender.view.transform.a-somefloat);

 CGFloat newRotation = initialRotation + sender.rotation;

 sender.view.transform = CGAffineTransformMakeRotation(newRotation);

试试上面的代码

于 2013-02-05T08:21:42.437 回答
-1

试试这个 :

- (IBAction)rotaehandler:(UIRotationGestureRecognizer *)sender
    {


        if ([sender state] == UIGestureRecognizerStateBegan || [sender state] ==  
                 UIGestureRecognizerStateChanged) 
        {
            [sender view].transform = CGAffineTransformRotate([[sender view] transform],  
                                                                [sender rotation]);

             NSLog(@"Rotate : %f",[gestureRecognizer rotation]);
             [sender setRotation:0];
         }
    }
于 2013-02-05T07:43:33.913 回答