iOS动画

===永久闪烁的动画=====

-(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;
}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • 目录 ** UIView 动画 ** ** Core Animation ** ** FaceBook POP动画...
    方向_4d0d阅读 1,656评论 0 3
  • 概览 在iOS中随处都可以看到绚丽的动画效果,实现这些动画的过程并不复杂,今天将带大家一窥iOS动画全貌。在这里你...
    Yiart阅读 3,865评论 3 34
  • 在iOS实际开发中常用的动画无非是以下四种:UIView动画,核心动画,帧动画,自定义转场动画。 1.UIView...
    请叫我周小帅阅读 3,159评论 1 23
  • 今天是正清明,昨夜妈的鼾声恼人。每次回学校心情都不好,离开了我的小港湾。不知为什么室友很不友好,所有不太想回学校。
    想找蓝亲故阅读 245评论 0 0
  • 很多财务人想报考CMA考试,但是又害怕CMA考试难度太大,就像CPA、ACCA一样,最终还是被迫选择放弃。那么管理...
    嗨呀很气阅读 517评论 0 0