core Animation之CATransition(转场动画)
用于做转场动画,能够为层提供移出屏幕和移入屏幕的动画效果。iOS比Mac OS X的转场动画效果少一点
UINavigationController就是通过CATransition实现了将控制器的视图推入屏幕的动画效果
属性解析:
type:动画过渡类型
subtype:动画过渡方向
startProgress:动画起点(在整体动画的百分比)
endProgress:动画终点(在整体动画的百分比)
代码一:
- #import "ViewController.h"
- @interface ViewController ()
- @property(nonatomic,strong)UIImageView *imgView;
- @end
- @implementation ViewController
- - (void)viewDidLoad {
- [super viewDidLoad];
- self.imgView=[[UIImageView alloc]initWithFrame:CGRectMake(100, 200, 200, 200)];
- [self.view addSubview:self.imgView];
- UIButton *btn1=[UIButton buttonWithType:UIButtonTypeCustom];
- [btn1 setTitle:@"上一张" forState:UIControlStateNormal];
- [btn1 addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- btn1.tag=1;
- btn1.backgroundColor=[UIColor redColor];
- btn1.frame=CGRectMake(50, 100, 80,40);
- [self.view addSubview:btn1];
- UIButton *btn2=[UIButton buttonWithType:UIButtonTypeCustom];
- [btn2 setTitle:@"下一张" forState:UIControlStateNormal];
- btn2.tag=2;
- [btn2 addTarget:self action:@selector(btnClick:) forControlEvents:UIControlEventTouchUpInside];
- btn2.frame=CGRectMake(150, 100, 80,40);
- btn2.backgroundColor=[UIColor redColor];
- [self.view addSubview:btn2];
- }
- -(void)btnClick:(id)sender
- {
- UIButton *btn=(UIButton *)sender;
- if (btn.tag==1) {
- self.imgView.image=[UIImage imageNamed:@"1.jpg"];
- CATransition *transition=[CATransition animation];
- //动画效果
- transition.type=@"push";
- //动画方向
- transition.subtype=kCATransitionFromRight;
- transition.duration=2.0;
- [self.imgView.layer addAnimation:transition forKey:nil];
- }
- else
- {
- self.imgView.image=[UIImage imageNamed:@"2.jpg"];
- CATransition *transition=[CATransition animation];
- transition.type=kCATransitionMoveIn;
- transition.subtype=kCATransitionFromBottom;
- transition.duration=2.0;
- [self.imgView.layer addAnimation:transition forKey:nil];
- }
- }
- - (void)didReceiveMemoryWarning {
- [super didReceiveMemoryWarning];
- // Dispose of any resources that can be recreated.
- }
- @end
代码二:
core Animation之CATransition(转场动画)的更多相关文章
- CATransition转场动画
背景: 最近在温习动画,分享个简单系统的转场动画 viewcontroller *VC=[self.storyboard instantiateViewControllerWithIdentifier ...
- 之四:CATransition - 转场动画
关键属性: type 过渡效果 kCATransitionFade 淡出 kCATransitionMoveIn 覆盖原图 kCATransitionPush 推出 kCATransition ...
- CATransition 转场动画解析
http://blog.csdn.net/mad2man/article/details/17260901
- iOS开发基础知识:Core Animation(核心动画)
Core Animation,中文翻译为核心动画,它是一组非常强大的动画处理API,使用它能做出非常炫丽的动画效果,而且往往是事半功倍.也就是说,使用少量的代码就可以实现非常强大的功能. Core A ...
- iOS之核心动画(Core Animation)
Core Animation,中文翻译为核心动画,它是一组非常强大的动画处理API,使用它能做出非常炫丽的动画效果,而且往往是事半功倍.也就是说,使用少量的代码就可以实现非常强大的功能. Core ...
- iOS - Core Animation 核心动画
1.UIView 动画 具体讲解见 iOS - UIView 动画 2.UIImageView 动画 具体讲解见 iOS - UIImageView 动画 3.CADisplayLink 定时器 具体 ...
- iOS动画-从UIView到Core Animation
首先,介绍一下UIView相关的动画. UIView普通动画: [UIView beginAnimations: context:]; [UIView commitAnimations]; 动画属性设 ...
- iOS开发 - Core Animation 核心动画
Core Animation Core Animation.中文翻译为核心动画,它是一组很强大的动画处理API,使用它能做出很炫丽的动画效果.并且往往是事半功倍. 也就是说,使用少量的代码就能够实现很 ...
- iOS - Core Animation(核心动画)
Core Animation,中文翻译为核心动画,它是一组非常强大的动画处理API,使用它能做出非常炫丽的动画效果,而且往往是事半功倍.也就是说,使用少量的代码就可以实现非常强大的功能.Core An ...
随机推荐
- NODE-WEBKIT教程(5)NATIVE UI API 之FRAMELESS WINDOW
node-webkit教程(5)Native UI API 之Frameless window 文/玄魂 原文链接:http://www.xuanhun521.com/Blog/2014/4/15/n ...
- openvSwitch 基本命令
建立ovs接口连接两个namespace组成二层网络 环境搭建拓扑 br0 +--------------------------------------+ +--+ +--+ +---+ | tap ...
- 使用Samba实现文件共享
1987年,微软公司和英特尔公司,共同制定了SMB(Server Messages Block 服务消息块)协议,指在解决局域网内的文件或打印机等资源的共享问题,这也使得在多个主机之间共享文件变得越来 ...
- 2018 Multi-University Training Contest 6
A.oval-and-rectangle 题目传送门:http://acm.hdu.edu.cn/showproblem.php?pid=6362 题意:在长半轴为a,短半轴为b的椭圆内部,以y=c( ...
- HDU - 2604 Queuing(递推式+矩阵快速幂)
Queuing Time Limit: 10000/5000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Su ...
- 读配置文件property文件
import java.io.IOException;import java.util.Properties; import org.springframework.core.io.support.P ...
- drf-序列化器的理解
序列化器作用: 1.进行数据的校验 2.对数据对象进行转换 序列化: 模型类对象 -----> python字典 用于输出, 返回给前端使用 反序列化: 前端传送的数据 --- ...
- B2C电商项目
经历四个月的自学. 结合所学的知识(HTML,CSS,javascript,jQuery,Mysql,Redis,Django,celery,fastDfs,haystack,whoosh,uWSGI ...
- 同时绑定onpropertychange 和 oninput 事件,实时检测 input、textarea输入改变事件,支持低版本IE,支持复制粘贴
实时检测 input.textarea输入改变事件,支持低版本IE,支持复制粘贴 检测input.textarea输入改变事件有以下几种: 1.onkeyup/onkeydown 捕获用户键盘输入事件 ...
- Hive中的Row_Number()使用
语法:row_number() over (partition by 字段a order by 计算项b desc ) rank --这里rank是别名 partition by:类似hive的建表, ...