像硬币一样旋转图像

我有一个形象。 我想旋转它像旋转在表面上的硬币 。 我试过旋转变换,但它不像那样旋转。 如何实现这样的animation?

在这里输入图像说明

码:

- (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"]; } 

ND:

 #import "LoginViewController.h" #import "RegistrationViewController.h" #import "ForgetPasswordViewController.h" #import "ForgetPasswordController.h" #import "SearchServiceProviderViewController.h" #import <QuartzCore/QuartzCore.h> 

这将使一个很好的, 像硬币般的翻转:

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

并将过渡animation添加到视图的图层中:

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

看到它在行动:

在这里输入图像说明

像这样旋转的一个很好的诀窍就是像旋转图像那样以不同的angular度拍摄不同的硬币图像。 然后将所有这些图像添加到数组,并开始使用该数组的图像animation..它会给你更好的效果…简单的过程,如video成帧。

喜欢:

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