0

我有一个问题。

我有这个代码:

if(CGRectContainsPoint(compassTarcsa.frame, curLoc))
{
    compassTarcsaTouch = YES;

    float fromAngle = atan2( compassFirstLoc.y-compassTarcsa.center.y,compassFirstLoc.x-compassTarcsa.center.x );
    float toAngle = atan2( curLoc.y-compassTarcsa.center.y,curLoc.x-compassTarcsa.center.x );

    newAngle = (angle + (toAngle - fromAngle));
    iranyFok = (newAngle / (M_PI / 180.0f))  ;


    if (iranyFok < 0.0f) {
        iranyFok += 360.0f;
    }

    iranyFok = 360-(fmodf(( 360 + iranyFok ), 360));

    CGAffineTransform cgaRotate = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(- iranyFok));

    compassTarcsa.transform = cgaRotate;
    repcsi.transform = CGAffineTransformMakeRotation(DEGREES_TO_RADIANS(iranyFok));

这会将指南针从 0 度旋转到 360 度,但对我来说旋转速度很快......

有人可以帮助我了解如何减慢这种旋转速度吗?

谢谢,

亚历克斯

4

2 回答 2

0

尝试这个:

[UIView animateWithDuration:2.0 delay:0 options: UIViewAnimationOptionCurveEaseInOut
  animations:^(void){
          compassTarcsa.transform = cgaRotate;
  } completion:NULL
];

这会将您的变换旋转包装在允许您控制旋转持续时间的动画中。

于 2013-10-25T08:37:04.457 回答
0

如果您想要对象的缓慢旋转,您应该考虑使用旋转动画并根据您所需的速度设置其持续时间。

以下链接可能对您有所帮助:

UIView无限360度旋转动画?

http://iosdevelopertips.com/user-interface/rotate-an-image-with-animation.html

于 2013-10-25T08:39:19.030 回答