ios 动画效果CATransition笔记
初学ios开发,很多概念还不清楚,所以只有边学边做例子。又怕学了后面忘了前面,因此用自己的博客来纪录自己的学习历程,也是对自己学习不要懈怠做个监督。
刚学ios做动画效果。因为ios封装得很好,实现ios的漂亮动画效果也很简单,却因为我自己的粗心落了一个字母 导致纠结了一天,这个教训必须记住,同时也懂得了调试技能在编程里地位也是非常重要的存在。
实现ios动画有两种方法:一种UIView层面的,一种是使用CATransition.
- - (void)viewDidLoad
- {
- [super viewDidLoad];
- // Do any additional setup after loading the view.
- UIView *redView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
- redView.backgroundColor = [UIColor redColor];
- [self.view addSubview:redView];
- UIView *yellowView = [[UIView alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
- yellowView.backgroundColor = [UIColor yellowColor];
- [self.view addSubview:yellowView];
- UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect];
- [button setTitle:@"改变1" forState:UIControlStateNormal];
- button.frame = CGRectMake(10, 10, 300, 40);
- [button addTarget:self action:@selector(changeUIView1) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:button];
- UIButton *button2 = [UIButton buttonWithType:UIButtonTypeRoundedRect];
- [button2 setTitle:@"改变2" forState:UIControlStateNormal];
- button2.frame = CGRectMake(10, 120, 300, 40);
- [button2 addTarget:self action:@selector(changeUIView2) forControlEvents:UIControlEventTouchUpInside];
- [self.view addSubview:button2];
- }
- -(void) changeUIView1{
- [UIView beginAnimations:@"animation" context:nil];
- [UIView setAnimationDuration:1.0f];
- [UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
- [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self.view cache:YES];
- [self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:0 ];
- [UIView commitAnimations];
- }
- -(void) changeUIView2{
- CATransition *transition = [CATransition animation];
- transition.delegate = self;
- transition.duration = 2.0f;
- transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseIn];
- transition.type = kCATransitionPush;
- transition.type = @"pageCurl" ;//另一种设置动画效果方法
- transition.subtype = kCATransitionFromBottom;
- [self.view exchangeSubviewAtIndex:1 withSubviewAtIndex:0];
- [self.view.layer addAnimation:transition forKey:@"animation"];
- }
调用CATransition需要在frameworks中添加QuartzCore.framework,在.h文件中加入 #import <QuartzCore/QuartzCore.h>
setType:有四种类型:
kCATransitionFade //交叉淡化过渡
kCATransitionMoveIn //移动覆盖原图
kCATransitionPush //新视图将旧视图推出去
kCATransitionReveal //底部显出来
另一种设置方法
pageCurl //向上翻一页
pageUnCurl //向下翻一页
rippleEffect //滴水效果
suckEffect //收缩效果,如一块布被抽走
cube //立方体效果
oglFlip //上下翻转效果
setSubtype:有四种类型:
kCATransitionFromRight;
kCATransitionFromLeft(默认值)
kCATransitionFromTop;
kCATransitionFromBottom
ios 动画效果CATransition笔记的更多相关文章
- iOS动画效果和实现
动画效果提供了状态或页面转换时流畅的用户体验,在iOS系统中,咱们不需要自己编写绘制动画的代码,Core Animation提供了丰富的api来实现你需要的动画效果. UIKit只用UIView来展示 ...
- iOS 动画效果:Core Animation & Facebook's pop
本文转载至 http://www.cocoachina.com/ios/20151223/14739.html 感谢原创作者分享 前言相信很多人对实现 iOS 中的动画效果都特别头疼,往往懒得动手,功 ...
- iOS动画效果集合、 通过摄像头获取心率、仿淘宝滑动样式、瀑布流、分类切换布局等源码
iOS精选源码 动画知识运用及常见动画效果收集 较为美观的多级展开列表 MUImageCache -简单轻量的图片缓存方案 iOS 瀑布流之栅格布局 一用就上瘾的JXCategoryView iOS ...
- iOS动画效果合集、飞吧企鹅游戏、换肤方案、画板、文字效果等源码
iOS精选源码 动画知识运用及常见动画效果收集 3D卡片拖拽卡片叠加卡片 iFIERO - FLYING PENGUIN 飞吧企鹅SpriteKit游戏(源码) Swift封装的空数据提醒界面Empt ...
- iOS UIView动画效果 学习笔记
//启动页动画 UIImageView *launchScreen = [[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds]; ...
- ios动画效果集锦(持续更新)
1.树叶滚动进度:http://www.jianshu.com/p/800496caa055 2.列表滚动动画和滚动视差效果http://www.jianshu.com/p/42e1eb59a1af ...
- iOS 动画效果。简单的提示消失
UILabel * label1 = [[UILabel alloc]initWithFrame:CGRectMake(, , , )]; label1.text = @"qingjoin& ...
- iOS开动画效果之──实现 pushViewController 默认动画效果
在开发中,视图切换会常常遇到,有时我们不是基于导航控制器的切换,但实际开发中,有时需要做成push效果,下面将如何实现push和pop 默认动画效果代码实例: 一.push默认动画效果 CATrans ...
- (转)iOS动画Core Animation
文章转载:http://blog.sina.com.cn/s/blog_7b9d64af0101b8nh.html 在iOS中动画实现技术主要是:Core Animation. Core Animat ...
随机推荐
- 2.5.2 使用alertdialog 创建列表对话框
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" android:layout ...
- 【POJ】2117 Electricity
无向图求割点和连通块. /* POJ2117 */ #include <iostream> #include <vector> #include <algorithm&g ...
- Jira在linux上安装与部署
Where should JIRA 6.0.1 be installed? [/opt/atlassian/jira] /usr/local/jira Default location for JIR ...
- nodejs之日志管理
开发一个项目时,可以通过控制台输出或者debug来获取到项目的运行信息.当项目上线时,我们就需要通过日志来分析.如同Java的log4j,nodejs中也有相关的log4js.使用过log4j的同学应 ...
- Linux Shell编程(26)——代码块重定向
像 while, until, 和 for 循环代码块, 甚至 if/then 测试结构的代码块都能做到标准输入的重定向. 即使函数也可以使用这种重定向的格式 .所有的这些依靠代码块结尾的 < ...
- Frontend Development
原文链接: https://github.com/dypsilon/frontend-dev-bookmarks Frontend Development Looking for something ...
- [转]让程序在崩溃时体面的退出之SEH+Dump文件
原文地址:http://blog.csdn.net/starlee/article/details/6649605 在我上篇文章<让程序在崩溃时体面的退出之SEH>中讲解了SEH中try/ ...
- [基础] Loss function(一)
Loss function = Loss term(误差项) + Regularization term(正则项),我们先来研究误差项:首先,所谓误差项,当然是误差的越少越好,由于不存在负误差,所以为 ...
- 《A First Course in Probability》-chaper7-极限定理-强大数定理
在现实问题中我们对于一个实验往往会重复成千上万次,那么我们就需要关注在实验次数趋于无穷之后,整个实验的期望会趋于怎样一个结果.其实这一章“极限定理”都是在处理这个问题. 强大数定理: 这里的证明过程给 ...
- ural 1333 化平面为点计算覆盖率
题目链接:http://acm.timus.ru/problem.aspx?space=1&num=1333 #include<cstdio> #include<cstrin ...