移动的触摸时图像旋转缓慢

时间:2013-05-31 12:16:01

标签: iphone image-rotation touchesmoved

我编写了一个程序,可以根据需要旋转我的imageView(CW或~CW)。 它工作正常。 但它反应非常缓慢,我希望它能够快速响应...... 你可以帮我解决一下吗? 提前致谢...!

以下是我的代码------------------------

-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
    {

        UITouch * touch = [[event allTouches]anyObject];
        CGPoint prevLoc = [touch previousLocationInView:self];
        CGPoint loc = [touch locationInView:self];

        if (isRotating) {

            float prevAngle = atan2(prevLoc.y-self.center.y,
                                    prevLoc.x-self.center.x);

            float newAngle = atan2( loc.y-self.center.y,
                                  loc.x-self.center.x);
            float finalAngle =angle+(newAngle-prevAngle);


            //Apply new transform
            CGAffineTransform rotateTransform = CGAffineTransformMakeRotation(Angle);

            self.transform=rotateTransform;
            angle = finalAngle;

        }
    }

0 个答案:

没有答案