动画

作者: 修木头 | 来源:发表于2016-02-24 20:48 被阅读0次

- (void)viewDidLoad {

[super viewDidLoad];

self.view.backgroundColor = [UIColor whiteColor];

UIButton *btn = [UIButton buttonWithType:UIButtonTypeSystem];

btn.frame = CGRectMake(100, 200, 100, 100);

btn.backgroundColor = [UIColor redColor];

[self.view addSubview:btn];

[btn setTitle:@"GoBack" forState:UIControlStateNormal];

[btn addTarget:self action:@selector(click:) forControlEvents:UIControlEventTouchUpInside];

}

-(void)click:(UIButton *)btn{

NSLog(@"~~~~动画~~~~~");

#if 0/* CABasicAnimation  */

//position 位置

//rotation  旋转

//scale  缩放

//通过keyPath(建路径: 对象的属性也是属性, 通过获取属性中的属性)

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

//持续时间

animation.duration = 1;

//起始状态

animation.fromValue = @(0.5);

//终止状态

animation.toValue = @(2);

//重复次数(默认为0)

animation.repeatCount = NSIntegerMax;

//自动恢复(默认为NO)

animation.autoreverses = YES;

//把动画添加给layer

//    [btn.layer addAnimation:animation forKey:@"scale"];

CABasicAnimation *animation1 = [CABasicAnimation animationWithKeyPath:@"transform.rotation"];

animation1.duration = 2;

animation1.fromValue = @(0);

animation1.toValue = @(M_PI * 2);

animation1.repeatCount = NSIntegerMax;

animation1.autoreverses = YES;

//    [btn.layer addAnimation:animation1 forKey:@"rotation"];

//组动画

CAAnimationGroup *group = [CAAnimationGroup animation];

//把动画添加到组中

group.animations = @[animation, animation1];

//重新设置动画组的属性

group.duration = 2;

group.repeatCount = NSIntegerMax;

[btn.layer addAnimation:group forKey:@"组动画"];

#endif

#if 0/* CAtransition */

CATransition *transition = [CATransition animation];

transition.duration = 2;

transition.repeatCount = NSIntegerMax;

//动画类型

//fade', `moveIn', `push' and `reveal'

/** type

*

*  各种动画效果  其中除了'fade', `moveIn', `push' ,  `reveal',其他属于私有的API.

*  ↑↑↑上面四个可以分别使用'kCATransitionFade', 'kCATransitionMoveIn', 'kCATransitionPush', 'kCATransitionReveal'来调用.

*  @"cube"                    立方体翻滚效果

*  @"moveIn"                  新视图移到旧视图上面

*  @"reveal"

显露效果(将旧视图移开,显示下面的新视图)

*  @"fade"                    交叉淡化过渡(不支持过渡方向)            (默认为此效果)

*  @"pageCurl"                向上翻一页

*  @"pageUnCurl"              向下翻一页

*  @"suckEffect"              收缩效果,类似系统最小化窗口时的神奇效果(不支持过渡方向)

*  @"rippleEffect"            滴水效果,(不支持过渡方向)

*  @"oglFlip"                  上下左右翻转效果

*  @"rotate"                  旋转效果

*  @"push"

*  @"cameraIrisHollowOpen"    相机镜头打开效果(不支持过渡方向)

*  @"cameraIrisHollowClose"    相机镜头关上效果(不支持过渡方向)

*/

/** type

*

*  kCATransitionFade            交叉淡化过渡

*  kCATransitionMoveIn          新视图移到旧视图上面

*  kCATransitionPush            新视图把旧视图推出去

*  kCATransitionReveal          将旧视图移开,显示下面的新视图

*/

transition.type = @"rippleEffect";

//动画方向

//kCATransitionFromRight kCATransitionFromLeft kCATransitionFromTop kCATransitionFromBottom

transition.subtype = kCATransitionFromRight;

[btn.layer addAnimation:transition forKey:@"go"];

//    //组动画

//    CAAnimationGroup *group = [CAAnimationGroup animation];

//    //把动画添加到组中

//    group.animations = @[animation, animation1, transition];

//    //重新设置动画组的属性

//    group.duration = 2;

//    group.repeatCount = NSIntegerMax;

//    [btn.layer addAnimation:group forKey:@"组动画"];

#endif

}

相关文章

  • 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/lxdbkttx.html