1.波浪效果是在tableView 上的cell上实现的,在cell.m中写如下代码:
- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
[super setSelected:selected animated:animated];
[self buttonAnimation];
}
2.动画方法:
- (CAAnimation *)animationRotate
{
// UIButton *theButton = sender;
// rotate animation
CATransform3D rotationTransform = CATransform3DMakeScale(1, 1, 1);
CATransform3D rotationTransform2 = CATransform3DMakeScale(1.1, 1.1, 1.1);
CABasicAnimation* animation;
animation = [CABasicAnimation animationWithKeyPath:@"transform"];
animation.toValue = [NSValue valueWithCATransform3D:rotationTransform2];
animation.fromValue = [NSValue valueWithCATransform3D:rotationTransform];
animation.duration = .5;
animation.autoreverses = YES;
animation.cumulative = YES;
animation.repeatCount = 1;
animation.beginTime = 0;
animation.delegate = self;
return animation;
}
- (void)animationDidStop:(CAAnimation *)anim finished:(BOOL)flag
{
// [self buttonAnimation];
}
- (void)buttonAnimation{
CAAnimation* myAnimationRotate = [self animationRotate];
CAAnimationGroup *m_pGroupAnimation = [CAAnimationGroup animation];
m_pGroupAnimation.delegate = self;
m_pGroupAnimation.removedOnCompletion = NO;
m_pGroupAnimation.duration = 1;
m_pGroupAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionLinear];
m_pGroupAnimation.repeatCount = 0;//FLT_MAX; //"forever";
m_pGroupAnimation.fillMode = kCAFillModeForwards;
m_pGroupAnimation.animations = [NSArray arrayWithObjects:myAnimationRotate,nil];
[self.layer addAnimation:m_pGroupAnimation forKey:@"animationRotate"];
}