• OC动画CABasicAnimation


    //1.创建动画
        CABasicAnimation *anima=[CABasicAnimation animationWithKeyPath:@"bounds"];
        //1.1设置动画执行时间
        anima.duration=2.0;
        //1.2设置动画执行完毕后不删除动画
        anima.removedOnCompletion=YES;
        //1.3设置保存动画的最新状态
        //kCAFillModeForwards保存动画的最新状态  kCAFillModeBackwards保存最开始状态
        anima.fillMode=kCAFillModeForwards;
        //1.4修改属性,执行动画
        anima.toValue=[NSValue valueWithCGRect:CGRectMake(0, 0, 200, 200)];
        //2.添加动画到layer
        [redView.layer addAnimation:anima forKey:nil];
    

     //1.创建动画
        CABasicAnimation *anima=[CABasicAnimation animationWithKeyPath:@"transform"];
        //1.1设置动画执行时间
        anima.duration=2.0;
        //1.2修改属性,执行动画
        anima.toValue=[NSValue valueWithCATransform3D:CATransform3DMakeRotation(M_PI_2+M_PI_4, 1, 1, 0)];
        //1.3设置动画执行完毕后不删除动画
        anima.removedOnCompletion=NO;
        //1.4设置保存动画的最新状态
        anima.fillMode=kCAFillModeBackwards;
        anima.repeatCount = 1000;
        
        //2.添加动画到layer
        [redView.layer addAnimation:anima forKey:nil];
    

     

    CABasicAnimation *anima=[CABasicAnimation animation];
        //1.1告诉系统要执行什么样的动画
        anima.keyPath=@"position";
        //设置通过动画,将layer从哪儿移动到哪儿
        anima.fromValue=[NSValue valueWithCGPoint:CGPointMake(0, 0)];
        anima.toValue=[NSValue valueWithCGPoint:CGPointMake(300, 300)];
        anima.duration = 1.0f;
        //1.2设置动画执行完毕之后不删除动画
        anima.removedOnCompletion=YES;
        //1.3设置保存动画的最新状态
        anima.fillMode=kCAFillModeForwards;
        //设置代理
        anima.delegate=self;
        //2.添加核心动画到layer
        [redView.layer addAnimation:anima forKey:nil];
    

    CABasicAnimation* rotationAnimation;
        rotationAnimation = [CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];
        rotationAnimation.toValue = [NSNumber numberWithFloat: M_PI * 2.0 ];
        rotationAnimation.duration = 1;
        rotationAnimation.cumulative = YES;
        rotationAnimation.repeatCount =  MAXFLOAT;
         [redView.layer addAnimation:rotationAnimation forKey:nil ];
    
     //透明动画
             CABasicAnimation *opacityAnim = [CABasicAnimation animationWithKeyPath:@"alpha"];
             opacityAnim.fromValue = [NSNumber numberWithFloat:1.0];
             opacityAnim.toValue = [NSNumber numberWithFloat:0.1];
             opacityAnim.removedOnCompletion = YES;
        
    
     //缩放动画
             CABasicAnimation *scaleAnim = [CABasicAnimation animationWithKeyPath:@"transform"];
             scaleAnim.fromValue = [NSValue valueWithCATransform3D:CATransform3DIdentity];
             scaleAnim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeScale(0.5, 0.5, 0.1)];
    
  • 相关阅读:
    打破国外垄断,开发中国人自己的编程语言(1):实现可以解析表达式的计算器
    the best way to get the OBJECTID OID name in arcpy?
    arcpy 自定义工具可选参数留空时的处理
    Word 显示隐藏图片
    删除Word表格后的一张空白页
    如何查看别人申请加群的历史记录
    OpenLayers v2 热力图插件
    IDEA JRebel热部署插件安装使用
    Lombok的@Data等注解无效
    CAP理论/AP架构/CP架构
  • 原文地址:https://www.cnblogs.com/hualuoshuijia/p/9946773.html
Copyright © 2020-2023  润新知