zoukankan      html  css  js  c++  java
  • CAniamtion 基本使用

    
    
    CAAnimation(抽象)<NSCoding, NSCopying, CAMediaTiming, CAAction>
    QuartzCore框架的基本继承结构

               -> 
    CATransition
    CAAnimation(抽象) -> CAPropertyAnimation -> CABasicAnimation
                             ->
    CAKeyframeAnimation
               -> 
    CAAnimationGroup
     
     






    //
    渐变 UIButton *b = (UIButton *)sender; CATransition *transition = [CATransition animation]; transition.type = kCATransitionPush; transition.subtype = kCATransitionFromRight; [self.imageview.layer addAnimation:transition forKey:@"transition"]; self.imageview.image = [UIImage imageNamed:@"avatar.jpg"]; //基本 CABasicAnimation *baseProperty = [CABasicAnimation animationWithKeyPath:@"transform.scale"]; baseProperty.fromValue = [NSNumber numberWithDouble:1.0]; baseProperty.toValue = [NSNumber numberWithDouble:0.4]; baseProperty.duration = 1.0; baseProperty.removedOnCompletion = NO; baseProperty.fillMode = kCAFillModeForwards; baseProperty.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; [self.imageview.layer addAnimation:baseProperty forKey:@"baseProperty"]; //关键帧 //动画组 CAKeyframeAnimation *keyFrameAniamtion = [CAKeyframeAnimation animationWithKeyPath:@"position"]; CGMutablePathRef mutablePath = CGPathCreateMutable(); CGPathMoveToPoint(mutablePath, NULL, self.imageview.frame.origin.x, self.imageview.frame.origin.y); CGPathAddLineToPoint(mutablePath, NULL, 0, 0); keyFrameAniamtion.path = mutablePath; keyFrameAniamtion.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseOut]; CAKeyframeAnimation *keyframe2 = [CAKeyframeAnimation animationWithKeyPath:@"transform.rotation"]; NSArray *values2 = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0], [NSNumber numberWithFloat:(M_PI * 10)], nil]; keyframe2.values = values2; keyframe2.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn]; CAAnimationGroup *group = [CAAnimationGroup animation]; group.removedOnCompletion = NO; group.fillMode = kCAFillModeForwards; group.animations = [NSArray arrayWithObjects:keyFrameAniamtion, keyframe2, nil]; group.duration = 2.0; [self.imageview.layer addAnimation:group forKey:@"group"];
  • 相关阅读:
    HTTP 协议中 URI 和 URL
    @Controller、@RestController
    java selvet 初学
    RocketMQ4.4 入门进阶+实战
    Spring Cloud微服务(一):公共模块的搭建
    Spring Boot 入门(十三):集成Hasor的Dataway模块,干掉后台,自动配置接口
    Spring Boot 入门(十二):报表导出,对比poi、jxl和esayExcel的效率
    Spring Boot 入门(十一):集成 WebSocket, 实时显示系统日志
    Spring Boot 入门(十):集成Redis哨兵模式,实现Mybatis二级缓存
    Spring Boot 入门(九):集成Quartz定时任务
  • 原文地址:https://www.cnblogs.com/apem/p/4608196.html
Copyright © 2011-2022 走看看