博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CAniamtion 基本使用
阅读量:5128 次
发布时间:2019-06-13

本文共 2268 字,大约阅读时间需要 7 分钟。

 
CAAnimation(抽象)
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"];

 

转载于:https://www.cnblogs.com/apem/p/4608196.html

你可能感兴趣的文章
npm 常用指令
查看>>
C#基础知识面试经典[整理]
查看>>
20几个正则常用正则表达式
查看>>
TextArea中定位光标位置
查看>>
非常棒的Visual Studo调试插件:OzCode 2.0 下载地址
查看>>
判断字符串在字符串中
查看>>
hdu4374One hundred layer (DP+单调队列)
查看>>
类间关系总结
查看>>
properties配置文件读写,追加
查看>>
Linux环境下MySql安装和常见问题的解决
查看>>
lrzsz——一款好用的文件互传工具
查看>>
ZPL语言完成条形码的打印
查看>>
这20件事千万不要对自己做!
查看>>
Linux环境下Redis安装和常见问题的解决
查看>>
Android开发中常见问题分析及解决
查看>>
玩转小程序之文件读写
查看>>
Android开发中UI相关的问题总结
查看>>
MySql Host is blocked because of many connection errors 问题的解决方法
查看>>
FastDFS高可用集群架构配置搭建及使用
查看>>
.tar.gz文件和.tar.xz文件的解压和压缩
查看>>