//  ViewController.m

//  IOS动画0817

//

//  Created by 张艳锋 on 15/8/17.

//  Copyright (c) 2015年 张艳锋. All rights reserved.

//

#import "ViewController.h"

@interface ViewController ()

@property (weak, nonatomic) IBOutlet UIImageView *imageview;

- (IBAction)doAnimationButton:(id)sender;

- (IBAction)doLeftButton:(id)sender;

- (IBAction)doRightButton:(id)sender;

- (IBAction)doUpButton:(id)sender;

- (IBAction)doDownButton:(id)sender;

@end

@implementation ViewController

- (void)viewDidLoad {

[super viewDidLoad];

// Do any additional setup after loading the view, typically from a nib.

}

- (void)didReceiveMemoryWarning {

[super didReceiveMemoryWarning];

// Dispose of any resources that can be recreated.

}

- (IBAction)doAnimationButton:(id)sender {

/********隐式动画********/

/*

[UIView beginAnimations:nil context:NULL];//动画开始标志

//定义一个仿射变换

CGAffineTransform moveTrans=CGAffineTransformMakeTranslation(300, 600);

// CGAffineTransformMakeTranslation//更改位置的函数

// CGAffineTransformMakeRotation//k控制旋转

//CGAffineTransformMakeScale//控制缩放

[_imageview.layer setAffineTransform:moveTrans];

[UIView commitAnimations];//提交动画

*/

/********显式动画********/

//定义显示动画的时候,我们不必定义CALayer的变化,也不必执行它,而是通过CABasicAnimation逐个定义动画,其中每个动画都含有各自的属性,然后通过addAnimation:方法添加到图层中

/*

CABasicAnimation *basic=[CABasicAnimation animationWithKeyPath:@"opacity"];//opacity表示透明度

basic.duration=6.0;//6秒内透明度变为零

basic.fromValue=[NSNumber numberWithFloat:0.2];//初始透明度

basic.toValue=[NSNumber numberWithFloat:1.0];//最终透明度

basic.cumulative=YES;//设置透明度递增

[_imageview.layer addAnimation:basic forKey:@"animateOpacity"];

CGAffineTransform moveTrans1=CGAffineTransformMakeTranslation(300, 600);

CABasicAnimation *basic_move=[CABasicAnimation animationWithKeyPath:@"transform"];//准备函数(为平移做准备)

basic_move.duration=6.0;

//CATransform3DMakeAffineTransform仿射变换为3D效果(仿射不能直接应用于显式动画)

basic_move.toValue=[NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(moveTrans1)];

[_imageview.layer addAnimation:basic_move forKey:@"animateTransform2"];

*/

/********关键帧动画********/

/*

CAKeyframeAnimation *keyAnimation=[CAKeyframeAnimation  animationWithKeyPath:@"opacity"];//透明度

keyAnimation.duration=6.0;//动画时间

keyAnimation.values=[NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0],[NSNumber numberWithFloat:0.6],[NSNumber numberWithFloat:1.0], nil];//

keyAnimation.keyTimes=[NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0],[NSNumber numberWithFloat:0.3],[NSNumber numberWithFloat:1.0], nil];

[_imageview.layer addAnimation:keyAnimation forKey:@"animateOpcaty"];

CGAffineTransform moveTrans2=CGAffineTransformMakeTranslation(300, 600);

CABasicAnimation *basic_move2=[CABasicAnimation animationWithKeyPath:@"transform"];

basic_move2.duration=6.0;

basic_move2.toValue=[NSValue valueWithCATransform3D:CATransform3DMakeAffineTransform(moveTrans2)];

[_imageview.layer addAnimation:basic_move2 forKey:@"animateTransform2"];

*/

}

//系统自带反转动画(上下左右)

- (IBAction)doLeftButton:(id)sender {

//三次向左不返回

[UIView beginAnimations:nil context:NULL];

[UIView setAnimationDuration:1.5f];//动画时间

[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];//设置动画曲线方式(动画的总体变化时间曲线,包含开始慢后来快,开始快后来慢,均匀曲线)

[UIView setAnimationRepeatAutoreverses:NO];//设置动画是否做一次反向操作

[UIView setAnimationRepeatCount:3];//执行次数

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.view cache:YES];//

[UIView commitAnimations];

}

- (IBAction)doRightButton:(id)sender {

//三次向右有返回

[UIView beginAnimations:nil context:NULL];

[UIView setAnimationDuration:1.5f];

[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

[UIView setAnimationRepeatAutoreverses:YES];

[UIView setAnimationRepeatCount:3];//执行次数

[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromRight forView:self.view cache:YES];

[UIView commitAnimations];

}

- (IBAction)doUpButton:(id)sender {

[UIView beginAnimations:nil context:NULL];

[UIView setAnimationDuration:1.5f];

[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

[UIView setAnimationRepeatAutoreverses:YES];

[UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self.view cache:YES];

[UIView commitAnimations];

}

- (IBAction)doDownButton:(id)sender {

[UIView beginAnimations:nil context:NULL];

[UIView setAnimationDuration:1.5f];

[UIView setAnimationCurve:UIViewAnimationCurveEaseOut];

[UIView setAnimationRepeatAutoreverses:YES];

[UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];

[UIView commitAnimations];

}

转载于:https://www.cnblogs.com/OIMM/p/4739097.html

IOS动画隐式,显式,翻页相关推荐

  1. iOS动画进阶(八)显式动画

    显式动画 如果想让事情变得顺利,只有靠自己 -- 夏尔·纪尧姆 上一章介绍了隐式动画的概念.隐式动画是在iOS平台创建动态用户界面的一种直接方式,也是UIKit动画机制的基础,不过它并不能涵盖所有的动 ...

  2. Android:新建一个Activity(隐式/显式),并携带数据

    新建一个Activity(隐式/显式),并携带数据 目录 新建一个Activity(隐式/显式),并携带数据 一.项目结构 二.隐式Activity 三.显式Activity 四.效果图(三个界面) ...

  3. iOS动效-利用CATransform3D实现翻页动画效果

    从事iOS开发已经有一段时间了,之前一直忙于工作,几乎很少有时间写一些东西来对自己掌握的技术进行一下总结,现在想想,有些后悔,因为之前在遇见问题的时候或者学习新技术的时候都是在翻看他人的博客或者查看苹 ...

  4. 4.1.4 OS之文件的物理结构(连续分配、链接分配[隐式-显式]、索引分配[链接方案-多层索引-混合索引])

    文章目录 0.思维导图 1.文件块.磁盘块 2.连续分配 3.链接分配 隐式链接 显式链接 链接分配总结 4.索引分配 链接方案 多层索引 混合索引 索引分配总结 5.文件物理结构分配总结 0.思维导 ...

  5. C语言隐式/显式类型转换 | C++四种强制类型转换、类的隐式转换、explicit

    文章目录 C语言类型转换 隐式类型转换 显式类型转换 C++ 强制类型转换 static_cast reinterpret_cast const_cast dynamic_cast 类的隐式类型转换 ...

  6. 操作系统之文件管理:5、文件物理结构(连续分配、链式(显式、隐式)分配、索引分配(链接、多层索引、混合索引))

    3.文件物理结构 思维导图 文件块.磁盘块 文件分配方式 1.连续分配 2.链接分配 隐式链接 显式链接 3.索引分配 如果一个文件的大小超过一个磁盘块怎么办? 1.链接方案 2.多层索引 3.混合索 ...

  7. java 范型 隐式 显式_隐式与显式接口实现

    用外行的话来说,如果一个类继承自2个或更多接口,并且这些接口碰巧具有相同的方法名,则如果您使用隐式接口实现,则该类将不知道正在实现哪种接口方法.这是您显式实现接口时的场景之一. 隐式接口实现 publ ...

  8. ios动态效果实现翻页_动画:UIKitAnimation 简单动画学习 iOS (一) 渐变 、 移动 、翻页、来回翻转 | 学步园...

    转载请说明(谢谢) http://blog.csdn.net/a21064346/article/details/7851695 以下 一个系列的 动画效果 在 UIView.h文件中可以查找.但是比 ...

  9. android 仿真翻页动画,Android 两Activity之间动画效果(1)---------翻页效果

    用Android rotate动画实现翻页效果,效果如图: 要实现上面动画,首先搞明白rotate动画原理: (1)Degrees坐标: 0度(360度) 270度 90度  顺时针旋转 180 (2 ...

  10. office在线预览哪家强?不能播放ppt动画,不能监听翻页?

    前言 众所周知,word.excel.ppt 和 pdf 文件在线预览有很多解决方案,但大多无法播放 ppt 动画,或者功能非常单一.这不,最近产品经理闭关修炼三天,提出了如下需求: 监听文档翻页,根 ...

最新文章

  1. u-boot移植问题记录(一)--U_BOOT_CMD区别
  2. Elon Musk的OpenAI用VR训练机器人:解锁更多复杂动作!
  3. 斯坦福统计学习理论笔记:Percy Liang带你搞定「贼难」的理论基础
  4. 第五章 MongoDb索引优化 5.6
  5. C语言:以scanf的使用为例,对缓冲区的理解
  6. 良心之作----centos6.5下安装svn客户端报错
  7. POJ1821 Fence
  8. Java8————Lambda表达式(二)
  9. Bash 入门教程10-处理用户输入
  10. google浏览器调试
  11. 17. QTreeView 简单用法
  12. identifier 'APP_FOLDER.EVENT' must be declared
  13. VirtualBox虚拟机如何扩容
  14. idea yml变成文件了_初识SpringBoot之配置文件(二)——配置文件值注入
  15. 工业大数据可视化面临的难点有哪些
  16. Deep3DFaceReconstruction让一张人脸照片变成三维的真人脸
  17. python查看函数帮助文档的方法
  18. word2007自动生成目录
  19. 方便快捷给 PDF 加水印
  20. Sequence and Swaps

热门文章

  1. C++ 编译运行报错 error: stray ‘\200’ in program 解决方案
  2. java并发编程(7)-- 线程 自旋锁
  3. 计算机管理文件和文件夹的实验结果及分析,实验1:文件和文件夹的管理
  4. 创建font_年底干货来了!图案创建、字体、图库、UI套件常见工具大合集!
  5. 思科路由器上配置了rip但是没有生成动态路由表_思科路由器 RIP、OSPF、EIGRP 路由协议最简单的配置实例详解...
  6. python语法学习第七天--文件
  7. JDBC13 ORM02 Map封装
  8. linux查找进程并删除文件,Linux find 查找 并删除文件 杀掉进程
  9. java 边界_Java泛型中的上下边界的理解
  10. Spring IOC三种注入方式(接口注入、setter注入、构造器注入)