zoukankan      html  css  js  c++  java
  • [转]CABasicAnimation 基本动画学习

    转自:http://blog.csdn.net/yanxiaoqing/article/details/7384339

    几个可以用来实现热门APP应用PATH中menu效果的几个方法

    +(CABasicAnimation *)opacityForever_Animation:(float)time //永久闪烁的动画

    {

    CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"opacity"];

        animation.fromValue=[NSNumber numberWithFloat:1.0];

        animation.toValue=[NSNumber numberWithFloat:0.0];

        animation.autoreverses=YES;

        animation.duration=time;

        animation.repeatCount=FLT_MAX;

        animation.removedOnCompletion=NO;

        animation.fillMode=kCAFillModeForwards;

    return animation;

    }

    +(CABasicAnimation *)opacityTimes_Animation:(float)repeatTimes durTimes:(float)time; //有闪烁次数的动画

    {

    CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"opacity"];

        animation.fromValue=[NSNumber numberWithFloat:1.0];

        animation.toValue=[NSNumber numberWithFloat:0.4];

        animation.repeatCount=repeatTimes;

        animation.duration=time;

        animation.removedOnCompletion=NO;

        animation.fillMode=kCAFillModeForwards;

        animation.timingFunction=[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];

        animation.autoreverses=YES;

    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.fillMode=kCAFillModeForwards;

    return animation;

    }

    +(CABasicAnimation *)moveY:(float)time Y:(NSNumber *)y //纵向移动

    {

    CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"transform.translation.y"];

        animation.toValue=y;

        animation.duration=time;

        animation.removedOnCompletion=NO;

        animation.fillMode=kCAFillModeForwards;

    return animation;

    }

    +(CABasicAnimation *)scale:(NSNumber *)Multiple orgin:(NSNumber *)orginMultiple durTimes:(float)time Rep:(float)repeatTimes //缩放

    {

    CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"transform.scale"];

        animation.fromValue=orginMultiple;

        animation.toValue=Multiple;

        animation.duration=time;

        animation.autoreverses=YES;

        animation.repeatCount=repeatTimes;

        animation.removedOnCompletion=NO;

        animation.fillMode=kCAFillModeForwards;

    return animation;

    }

    +(CAAnimationGroup *)groupAnimation:(NSArray *)animationAry durTimes:(float)time Rep:(float)repeatTimes //组合动画

    {

    CAAnimationGroup *animation=[CAAnimationGroup animation];

        animation.animations=animationAry;

        animation.duration=time;

        animation.repeatCount=repeatTimes;

        animation.removedOnCompletion=NO;

        animation.fillMode=kCAFillModeForwards;

    return animation;

    }

    +(CAKeyframeAnimation *)keyframeAniamtion:(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 *)movepoint:(CGPoint )point //点移动

    {

    CABasicAnimation *animation=[CABasicAnimation animationWithKeyPath:@"transform.translation"];

        animation.toValue=[NSValue valueWithCGPoint:point];

        animation.removedOnCompletion=NO;

        animation.fillMode=kCAFillModeForwards;

    return animation;

    }

    +(CABasicAnimation *)rotation:(float)dur degree:(float)degree direction:(int)direction repeatCount:(int)repeatCount //旋转

    {

    CATransform3D rotationTransform  = CATransform3DMakeRotation(degree, 0, 0,direction);

    CABasicAnimation* animation;

        animation = [CABasicAnimation animationWithKeyPath:@"transform"];

    animation.toValue= [NSValue valueWithCATransform3D:rotationTransform];

        animation.duration= dur;

    animation.autoreverses= NO;

        animation.cumulative= YES;

        animation.removedOnCompletion=NO;

        animation.fillMode=kCAFillModeForwards;

        animation.repeatCount= repeatCount;

    animation.delegate= self;

    return animation;

    }

  • 相关阅读:
    HttpContext 来源(System.Web.HttpContext.Current值为null的问题)
    属性" ******** "的代码生成失败.错误是:"程序集"********.Version=1.0.0.0,Culture=neutral,..........无标记为序列化""](转)
    什么是cookie?session和cookie的区别?
    Java中有多少种设计模式?请简单画一下三种常见设计模式的类图?
    Java中抽象类和接口的区别?
    JRE 和 JDK 的区别是什么?
    Hibernate中Criteria的完整用法?
    正则表达式ab?c匹配的字符串是?(B)
    下面forward和redirect的描述,正确的是(ABCD)
    springMVC中的中心控制Servlet是那个类?(B)
  • 原文地址:https://www.cnblogs.com/dukewell/p/3022378.html
Copyright © 2011-2022 走看看