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 ...
随机推荐
- 增加显示记录数的label及隐藏refresh按钮
1. 在UniDBgrid的extEvent属性中写入以下代码: function OnAfterCreate(sender) { var toolbar=sender.getDockedItems( ...
- Android-okhttp下载网络图片并设置壁纸
在AndroidManifest.xml配置网络访问权限: <!-- 访问网络是危险的行为 所以需要权限 --> <uses-permission android:name=&quo ...
- deeplearning 源码收集
Theano – CPU/GPU symbolic expression compiler in python (from MILA lab at University of Montreal) To ...
- 工作随笔——elasticsearch数据冷热分离、数据冷备
概述: 适合日志类型的数据存储方案.即当日数据写入,历史数据只读. 节省部分硬件成本.热数据采用更好的硬件. 环境: 已有6个ES节点,使用docker-compose方式搭建. es1:master ...
- C#中解析JSON数据,并获取到其中的值
1.应需求创建一个Json字符串 string json = "[{'Name':'张三','age':'20','Data':{'ID':100,'heigh':'180','weight ...
- 背水一战 Windows 10 (53) - 控件(集合类): ItemsControl 的布局控件 - ItemsStackPanel, ItemsWrapGrid
[源码下载] 背水一战 Windows 10 (53) - 控件(集合类): ItemsControl 的布局控件 - ItemsStackPanel, ItemsWrapGrid 作者:webabc ...
- [R]关于R语言的绘图函数
1. 首先就是plot(x,y,...) 参数: x: 所绘图形横坐标构成的对象 y: 所绘图形纵坐标构成的对象 type: 指定所绘图形类型 pch: 指定绘制点时使用的符号 cex: 指定符号的大 ...
- .NET Core中使用EF Core连接MySQL
最近一直在捣鼓.NET Core方面的东西,顺便写下点东西记录下 1.打开vs2017,新建一个项目 2.vs会自动生成一个项目,然后打开NuGet搜索MySql.Data.EntityFramewo ...
- Lucene使用案例
Lucene是apache软件基金会4 jakarta项目组的一个子项目,是一个开放源代码的全文检索引擎工具包,但它不是一个完整的全文检索引擎,而是一个全文检索引擎的架构,提供了完整的查询引擎和索引引 ...
- SQLYog执行SQL脚本提示:错误代码: 1067 - Invalid default value for '数据库表'查询:解决办法
强烈建议:完全卸载当前版本MySQL,重新安装5.6及以上版本 完全卸载方法:https://jingyan.baidu.com/article/3d69c551611290f0ce02d77b.ht ...