Madhu
Madhu

Reputation: 994

Rotate(Fixed End) an imageView with Animation Between Two angles

Hi i am developing an application which needs image animation between two angles.ie from 0-90 and then 90-0 degrees after image reaches to 0 degrees ,Animation has to stop.

I am using the following code it is giving animation from 0-90 only, but also i need to get the image to 0 with animation from 90.

               [UIView animateWithDuration: 0.5f
                     delay: 0.0f
                   options: options
                animations: ^{
                   self.imageToMove.transform = CGAffineTransformRotate(imageToMove.transform, M_PI / 2);
                }
                completion: ^(BOOL finished) {
                   if (finished) {
                         // if flag still set, keep spinning with constant speed
                         [self spinWithOptions: UIViewAnimationOptionCurveLinear];
                      } 
                   }
                }];

Any help please....

Upvotes: 1

Views: 373

Answers (1)

Vishal
Vishal

Reputation: 556

Try this by changeing value of "RADIANS"

    #define RADIANS(degrees) ((degrees * M_PI) / 180.0)

//- (void)startWobble 

-(IBAction)start:(id)sender

{

    itemView.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(-1));

    [UIView animateWithDuration:0.15 delay:0.0 options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionRepeat | UIViewAnimationOptionAutoreverse)

                     animations:^ {

                         itemView.transform = CGAffineTransformRotate(CGAffineTransformIdentity, RADIANS(1));

                     }

                     completion:NULL

     ];

}

//- (void)stopWobble 

-(IBAction)end:(id)sender

{

    [UIView animateWithDuration:0.25

                          delay:0.0 

                        options:(UIViewAnimationOptionAllowUserInteraction | UIViewAnimationOptionBeginFromCurrentState | UIViewAnimationOptionCurveLinear)

                     animations:^ {

                         itemView.transform = CGAffineTransformIdentity;

                     }

                     completion:NULL

     ];

}

Upvotes: 1

Related Questions