动画

作者: 与世倾听X游定终生 | 来源:发表于2016-01-11 13:38 被阅读38次

首先引入框架:QuartzCore.framework

在头文件声明:CALayer *logoLayer

{

//界限

CABasicAnimation *boundsAnimation = [CABasicAnimationanimationWithKeyPath:@"bounds"];

boundsAnimation.fromValue = [NSValue valueWithCGRect:logoLayer.bounds];

boundsAnimation.toValue = [NSValue valueWithCGRect:CGRectZero];

//透明度变化

CABasicAnimation *opacityAnimation = [CABasicAnimationanimationWithKeyPath:@"opacity"];

opacityAnimation.fromValue = [NSNumber numberWithFloat:1.0];

opacityAnimation.toValue = [NSNumber numberWithFloat:0.5];

//位置移动

CABasicAnimation *animation  = [CABasicAnimation animationWithKeyPath:@"position"];

animation.fromValue =  [NSValue valueWithCGPoint:logoLayer.position];

CGPoint toPoint =logoLayer.position;

toPoint.x += 180;

animation.toValue = [NSValue valueWithCGPoint:toPoint];

//旋转动画

CABasicAnimation* rotationAnimation =

[CABasicAnimation animationWithKeyPath:@"transform.rotation.z"];//"z"还可以是“x”“y”,表示沿z轴旋转

rotationAnimation.toValue = [NSNumber numberWithFloat:(2 * M_PI) * 3];

// 3 is the number of 360 degree rotations

// Make the rotation animation duration slightly less than the other animations to give it the feel

// that it pauses at its largest scale value

rotationAnimation.duration = 2.0f;

rotationAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];//缓入缓出

//缩放动画

CABasicAnimation *scaleAnimation = [CABasicAnimation animationWithKeyPath:@"transform.scale"];

scaleAnimation.fromValue = [NSNumber numberWithFloat:0.0];

scaleAnimation.toValue = [NSNumber numberWithFloat:1.0];

scaleAnimation.duration = 2.0f;

scaleAnimation.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];

CAAnimationGroup *animationGroup = [CAAnimationGroup animation];

animationGroup.duration = 2.0f;

animationGroup.autoreverses = YES;//是否重播,原动画的倒播

animationGroup.repeatCount =NSNotFound;//HUGE_VALF;     //HUGE_VALF,源自math.h

[animationGroup setAnimations:[NSArray arrayWithObjects:rotationAnimation, scaleAnimation, nil]];

//将上述两个动画编组

[logoLayer addAnimation:animationGroup forKey:@"animationGroup"];

}

//去掉所有动画

[logoLayer removeAllAnimations];

//去掉key动画

[logoLayer removeAnimationForKey:@"animationGroup"];

1.动画讲解,非常详细,基础

相关文章

  • Android回顾--(十六) 动画简析

    动画: 补间动画(Tween动画) 帧动画(Frame动画) 属性动画(Property动画) 补间动画 特点: ...

  • 在山西太原,做个二维动画需要哪些制作流程?

    二维动画有哪些类型? flash动画,课件动画,mg动画,ae动画,GIF动画,手绘动画,网页动画,企业动画,宣传...

  • Android 动画

    【Android 动画】 动画分类补间动画(Tween动画)帧动画(Frame 动画)属性动画(Property ...

  • 动画学习

    动画 分为 组动画,属性动画,渐变动画,其中属性动画包括 普通动画和关键帧动画,其他动弹动画,动画层分为 pres...

  • Android动画

    Android动画分类: 视图动画:补间动画、逐帧动画 属性动画 视图动画 补间动画 可以在xml中定义动画,然后...

  • iOS动画

    iOS动画-从UIView动画说起iOS动画-Transform和KeyFrame动画iOS动画-layout动画...

  • Android动画之视图动画

    分类 Android动画主要包括视图动画和属性动画。视图动画包括Tween动画和Frame动画。Tween动画又包...

  • Android 动画

    android动画分为三种 帧动画,视图动画(补间动画),属性动画逐帧动画 视图动画 属性动画 Window和A...

  • android动画

    动画: 分类:分为视图动画和属性动画,其中视图动画又分为补间动画和逐帧动画。补间动画又分为平移动画、缩放动画、旋转...

  • Android中的动画概述

    动画可以分为三类:View动画,帧动画,属性动画。 一、View动画 1.View动画包括四种:平移动画,缩放动画...

网友评论

    本文标题:动画

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