- (CAAnimation *)animationRotate
{
// UIButton *theButton = sender;
// rotate animation
CATransform3D rotationTransform = CATransform3DMakeRotation(M_PI, 0.5, -0.5,0.5);
CABasicAnimation* animation;
animation = [CABasicAnimation animationWithKeyPath:@"transform"];
animation.toValue = [NSValuevalueWithCATransform3D:rotationTransform];
animation.duration = 0.3;
animation.autoreverses = YES;
animation.cumulative = YES;
animation.repeatCount = 1;
animation.beginTime = 0.1;
animation.delegate = self;
return animation;
}
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
//todo
}
- (void)buttonAnimation:(id) sender
{
UIButton *theButton = sender;
CAAnimation* myAnimationRotate = [selfanimationRotate];
CAAnimationGroup *m_pGroupAnimation = [CAAnimationGroupanimation];
m_pGroupAnimation.delegate =self;
m_pGroupAnimation.removedOnCompletion =NO;
m_pGroupAnimation.duration =1;
m_pGroupAnimation.timingFunction = [CAMediaTimingFunctionfunctionWithName:kCAMediaTimingFunctionEaseInEaseOut];
m_pGroupAnimation.repeatCount =1;//FLT_MAX; //"forever";
m_pGroupAnimation.fillMode =kCAFillModeForwards;
m_pGroupAnimation.animations = [NSArrayarrayWithObjects:myAnimationRotate,nil];
[theButton.layer addAnimation:m_pGroupAnimationforKey:@"animationRotate"];
}