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"];
  • 相关阅读:
    Word中封面的问题
    UML问题
    《十八岁的天空》有感
    SPSS相关和回归分析
    WinForm自定义验证控件
    .NET常用的扩展方法整理
    C# 对JS编码/解码进行转换
    Jquery AJAX 调用WebService服务
    多条件动态LINQ 组合查询
    Visual studio 2008 的语法高亮插件 WordLight
  • 原文地址:https://www.cnblogs.com/apem/p/4608196.html
Copyright © 2011-2022 走看看