geminiCoder
geminiCoder

Reputation: 2906

How (if possible) can I set the duration of a CGAffineTransformRotate

I Have a standard CGAffineTransformRotate in my code rotating a CALayer. I haven't been able to work out how to set the duration of the animation.

Any Ideas?

Thank you David I was able to find what I needed thanks to your comment. Sometimes I think you just need a fresh perspective after staring at a screen for 8 hours, Cheers.

Jake

The developer doc. The answer is buried in here.

Upvotes: 0

Views: 109

Answers (1)

Floris497
Floris497

Reputation: 1406

this code may help you

// if you dont use this code with a UIButton cange the UIButton befor the "animateWithDuration:"

- (IBAction)rotate:(id)sender {

        [UIButton animateWithDuration:1.0 /* <---- duration of the animation (float)*/

                           animations:^{   /*block for animation*/

                               CGAffineTransform rotate = CGAffineTransformMakeRotation( 360 /* <---- Rotation degrees*/ / 180.0 * M_PI );
                               [button setTransform:rotate];

                             }
                         completion:^(BOOL finished){ /*code block triggerd when animation is done*/ }];

        // if here is an NSLog it wil probably be triggerd befor the animation ends

    }

Upvotes: 2

Related Questions