美文网首页
animaiton各种好玩动画·3

animaiton各种好玩动画·3

作者: seventhboy | 来源:发表于2018-01-09 16:49 被阅读9次

第一种,渐变色变化
CAGradientLayer *gradient = [CAGradientLayer layer];
CGRect rect = CGRectMake(200, 100, 100, 100);
gradient.frame = rect;
gradient.colors = [NSArray arrayWithObjects:(id)[UIColor blueColor].CGColor,
(id)[UIColor whiteColor].CGColor,
nil];
[self.view.layer insertSublayer:gradient atIndex:0];

第二种,透明-显示
CABasicAnimation *opAnim = [CABasicAnimation animationWithKeyPath:@"opacity"];
opAnim.duration = 3.0;
opAnim.fromValue = [NSNumber numberWithFloat:.25];
opAnim.toValue = [NSNumber numberWithFloat:1.0];
opAnim.cumulative = NO;//不累积
opAnim.repeatCount = MAXFLOAT;
[_planeView.layer addAnimation:opAnim forKey:@"animateOpacity"];
第三种,移动位置
CGAffineTransform moveTransform = CGAffineTransformMakeTranslation(10, 200);
CABasicAnimation *moveAnim = [CABasicAnimation animationWithKeyPath:@"transform"];
moveAnim.duration = 2.0;
moveAnim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(moveTransform)];
moveAnim.removedOnCompletion = NO;//必须要设置为no,用CAAnimation必须这样设置。
moveAnim.cumulative = YES;

moveAnim.fillMode = kCAFillModeBoth;
[_planeView.layer addAnimation:moveAnim forKey:@"animateTransform"];

第四种,组合移动位置
CAKeyframeAnimation *opAnim = [CAKeyframeAnimation animationWithKeyPath:@"opacity"];
opAnim.duration = 6.0;
opAnim.values = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.25], [NSNumber numberWithFloat:0.75], [NSNumber numberWithFloat:1.0], nil];
opAnim.keyTimes = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0], [NSNumber numberWithFloat:0.5], [NSNumber numberWithFloat:1.0], nil];
[_planeView.layer addAnimation:opAnim forKey:@"animateOpacity"];

CGAffineTransform moveTransform = CGAffineTransformMakeTranslation(180, 200);
CABasicAnimation *moveAnim = [CABasicAnimation animationWithKeyPath:@"transform"];
moveAnim.duration = 6.0;
moveAnim.toValue = [NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(moveTransform)];
[_planeView.layer addAnimation:moveAnim forKey:@"animateTransform"];

相关文章

  • animaiton各种好玩动画·3

    第一种,渐变色变化CAGradientLayer *gradient = [CAGradientLayer lay...

  • animaiton各种好玩动画·1

    第一种,撞边框回弹效果{CGMutablePathRef starPath = CGPathCreateMutab...

  • animaiton各种好玩动画·2

    @property (nonatomic) CATransition *transition;//全局变量 aa ...

  • 隐式动画

    1、隐式动画是Core Animaiton的默认行为,当改变图层的动画属性时,能从先前值平滑过渡到新的值,而不是立...

  • I.6 特定图层(下)

    AVPlayerLayer 最后我们将讲解AVPlayerLayer。尽管它不是Core Animaiton框架中...

  • Unity动画状态机

    动画状态机: 1、用来管理3D模型要执行的各种动画状态 2、AnimatorController:Assets->...

  • instrument工具

    instrument使用 参考:Core Animaiton工具内存泄漏检测instrument使用 路径:Xco...

  • css做立方体

    css3可以用来做动画,是给网页做各种特效的神器。它新增了多个做动画的属性,比如translate3d、cu...

  • 你想到的各种好玩,你想不到的各种好玩

    你想到的各种好玩,你想不到的各种好玩 ——读《企鹅、凤梨和穿山甲》 苇眉儿/文 克莱尔·科克-斯塔基是英国的一位作...

  • UIDynamic动画(很好玩)

    最近公司的项目有点紧,这段时间抽时间整理下关于UIDynamic的思路,现在将牛顿摆锤动画做一个简单的实现. 根据...

网友评论

      本文标题:animaiton各种好玩动画·3

      本文链接:https://www.haomeiwen.com/subject/qekgnxtx.html