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 ...
随机推荐
- leetcode面试准备: Jump Game
1 题目 Given an array of non-negative integers, you are initially positioned at the first index of the ...
- Bluetooth LE(低功耗蓝牙) - 第五部分
回顾: 在本系列前面的文章中我们完成了发现BLE传感器并与之建立连接.现在只剩下从其中获取数据了,但是这并没有看起来那么简单.在这篇文章中我们将讨论GATT的特点以及如何促进主机与传感器之间的数据交换 ...
- (转载)PHP json_encode() 函数介绍
(转载) 在 php 中使用 json_encode() 内置函数(php > 5.2)可以使用得 php 中数据可以与其它语言很好的传递并且使用它. 这个函数的功能是将数值转换成json数据存 ...
- MessageFormat.format处理单引号和大括号
在MessageFormat.format方法中组装jason数据字符串:{code:"w1",des:"w2"},起止分别有左大括号和右大括号.方法是将单引号 ...
- Lowest Common Ancestor of a Binary Tree——Leetcode
Given a binary tree, find the lowest common ancestor (LCA) of two given nodes in the tree. According ...
- unity3d Human skin real time rendering with blood and water drop effect真实模拟人皮实时渲染之血液和水珠掉落效果
在之前的一篇(链接在此)文章中写了下关于真实模拟皮肤渲染,在此基础之上又想加上血液效果,在洗澡的时候(= =:)又想在skin上加上水珠的效果,所以研究了下,做出来效果感觉还不错,放下效果图: 水珠 ...
- leetcode shttps://oj.leetcode.com/problems/surrounded-regions/
1.从外围搜索O,深度搜索出现了 Line 35: java.lang.StackOverflowError Last executed input: ["OOOOOOOOOOOOOOOOO ...
- Sorting Algorithm
sorting 应该是最容易被考到的东西,自己老是学了背,背了忘.为了方便复习,这里进行总结 1. Bubble Sort 定义:每两个两个比较,每扫完一次,当前扫过的最大值放在了末尾. for i ...
- iOS10-配置获取隐私数据权限声明
iOS10中,苹果加强了对用户隐私数据的保护,在访问以下数据的时候都需要在info.list重配置privacy,进行声明,否则程序无法正常运行. Contacts, Calendar, Remind ...
- centos 6.5上部署jetty
和tomcat是一样的,在部署容器之前,我们首先得有java环境 这里我们选择用rpm包的方式安装jdk 这里我们上传我之前下载好的jdk包 然后按照该文章http://blog.csdn.net/x ...