0

I have an issue.

i have this code:

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));

This rotates a compass from 0 to to 360 degrees, but the rotation speed is fast for me...

Can somebody help me understand how to slow this rotate?

Thx,

Alex

itsbruce
  • 4,825
  • 26
  • 35

2 Answers2

0

Try this:

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

This will wrap your transform rotation in an animation that allows you to control the rotation duration.

sergio
  • 68,819
  • 11
  • 102
  • 123
0

You should consider using rotation animation and set its duration as per your required speed if you want slow rotation of an object.

Following links may be helpful to you:

UIView Infinite 360 degree rotation animation?

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

Community
  • 1
  • 1
Neha
  • 1,751
  • 14
  • 36