Twisting the image around like a coin

I have one image. I want it to spin like a coin on the surface. I tried rotation conversion, but it does not rotate. How to achieve such an animation?

enter image description here

code:

- (void)viewDidLoad { [super viewDidLoad]; [self.view setUserInteractionEnabled:YES]; lbl_facebook.font=[UIFont fontWithName:GZFont size:12.0f]; txtPassword.font=[UIFont fontWithName:GZFont size:15.0f]; txtUsername.font=[UIFont fontWithName:GZFont size:15.0f]; CATransition* transition = [CATransition animation]; transition.startProgress = 0; transition.endProgress = 1.0; transition.type = @"flip"; transition.subtype = @"fromRight"; transition.duration = 0.3; transition.repeatCount = 2; [_Image.layer addAnimation:transition forKey:@"transition"]; } 

th:

 #import "LoginViewController.h" #import "RegistrationViewController.h" #import "ForgetPasswordViewController.h" #import "ForgetPasswordController.h" #import "SearchServiceProviderViewController.h" #import <QuartzCore/QuartzCore.h> 
+6
source share
2 answers

One good trick to spin like this is to take different coin images with different angles, like a spinning image. And then add all these images to the array and start animating the images with this array. This will give you a much better effect ... A simple process such as creating a video.

how

 NSArray *animationArray = [NSArray arrayWithObjects: [UIImage imageNamed:@"images.jpg"], [UIImage imageNamed:@"images1.jpg"], [UIImage imageNamed:@"images5.jpg"], [UIImage imageNamed:@"index3.jpg"], nil]; UIImageView *animationView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0,320, 460)]; animationView.backgroundColor = [UIColor purpleColor]; animationView.animationImages = animationArray; animationView.animationDuration = 1.5; animationView.animationRepeatCount = 0; [animationView startAnimating]; 
+2
source

This will make a nice coin-like flip:

 CATransition* transition = [CATransition animation]; transition.startProgress = 0; transition.endProgress = 1.0; transition.type = @"flip"; transition.subtype = @"fromRight"; transition.duration = 0.3; transition.repeatCount = 2; 

And add the transition animation to the layer of your view:

 [_yourView.layer addAnimation:transition forKey:@"transition"]; 

See in action:

enter image description here

+19
source

All Articles