===永久闪烁的动画=====
-(CABasicAnimation *)opacityForever_Animation:(float)time
{
//必须写opacity才行
CABasicAnimation *animation =[CABasicAnimation animationWithKeyPath:@"opacity"];
animation.fromValue =[NSNumber numberWithFloat:1.0f];
animation.toValue =[NSNumber numberWithFloat:0.0f];//这是透明度
animation.autoreverses = YES;
animation.duration =time;
animation.repeatCount =MAXFLOAT;
animation.removedOnCompletion =NO;
animation.fillMode =kCAFillModeForwards;
animation.timingFunction =[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
return animation;
}
======横向 纵向移动=======
-(CABasicAnimation *)moveX:(float)time X:(NSNumber *)x
{
CABasicAnimation *animation =[CABasicAnimation animationWithKeyPath:@"transform.translation.x"];
animation.toValue =x;
animation.duration =time;
animation.removedOnCompletion =NO;
animation.repeatCount =MAXFLOAT;
animation.fillMode =kCAFillModeForwards;
return animation;
}
=========缩放======
-(CABasicAnimation *)scale:(NSNumber *)Multiple orgin:(NSNumber *)orginMultiple durTimes:(float)time
Rep:(float)repertTimes
{
CABasicAnimation *animation =[CABasicAnimation animationWithKeyPath:@"transform.scale"];
animation.fromValue =Multiple;
animation.toValue =orginMultiple;
animation.autoreverses =YES;
animation.repeatCount =repertTimes;
animation.duration =time;
animation.removedOnCompletion =NO;
animation.fillMode =kCAFillModeForwards;
return animation;
}
------组合动画
-(CAAnimationGroup *)groupAnimation:(NSArray *)animationArray durTimes:(float)time Rep:(float)repeatTimes
{
CAAnimationGroup *animation =[CAAnimationGroup animation];
animation.animations =animationArray;
animation.duration =time;
animation.removedOnCompletion =NO;
animation.repeatCount =repeatTimes;
animation.fillMode =kCAFillModeForwards;
return animation;
}
-----路径动画-------
-(CAKeyframeAnimation *)keyframeAnimation:(CGMutablePathRef)path durTimes:(float)time Rep:(float)repeatTimes
{
CAKeyframeAnimation *animation =[CAKeyframeAnimation animationWithKeyPath:@"position"];
animation.path =path;
animation.removedOnCompletion =NO;
animation.fillMode =kCAFillModeForwards;
animation.timingFunction =[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
animation.autoreverses = NO;
animation.duration =time;
animation.repeatCount =repeatTimes;
return animation;
}
-(CABasicAnimation *)rotation:(float)dur degree:(float)degree direction:(int)direction repeatCount:(int)repeatCount
{
CATransform3D rotationTransform =CATransform3DMakeRotation(degree, 0, 0, direction);
CABasicAnimation *animation =[CABasicAnimation animationWithKeyPath:@"transform"];
animation.toValue =[NSValue valueWithCATransform3D:rotationTransform];
animation.duration =dur;
animation.autoreverses =NO;
animation.cumulative =NO;
animation.fillMode =kCAFillModeForwards;
animation.repeatCount =repeatCount;
animation.delegate =self;
return animation;
}