UIKit Animation
UIKit Animation
1.属性动画
- (void)changeFrameAnimation {
[UIView beginAnimations:@"frameAnimation" context:nil];
[UIView setAnimationDuration:0.8];
[UIView setAnimationDelegate:self];
[UIView setAnimationWillStartSelector:@selector(startAnimation:)];
[UIView setAnimationDidStopSelector:@selector(stopAnimation:)];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationRepeatCount:1];
// [UIView setAnimationRepeatAutoreverses:YES];
self.secondView.frame = self.firstView.frame;
[UIView commitAnimations];
}
2.Transition 提供了一个图层变化的过渡效果,它能影响图层的整个内容
- (void)transitionAnimation {
[UIView beginAnimations:@"frameAnimation" context:nil];
[UIView setAnimationDuration:0.8];
[UIView setAnimationDelegate:self];
[UIView setAnimationWillStartSelector:@selector(startAnimation:)];
[UIView setAnimationDidStopSelector:@selector(stopAnimation:)];
[UIView setAnimationCurve:UIViewAnimationCurveLinear];
[UIView setAnimationRepeatCount:1];
self.firstView.backgroundColor = [UIColor purpleColor];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.firstView cache:YES]; // 转场效果,forView 动画作用对象
[UIView commitAnimations];
}
- Block Animation
- (void)block1 {
[UIView animateWithDuration:0.8 animations:^{
self.secondView.frame = self.firstView.frame;
}];
}
- (void)block2 {
[UIView animateWithDuration:0.8 animations:^{
self.secondView.frame = self.firstView.frame;
} completion:^(BOOL finished) {
NSLog(@"complete blockAnimation");
}];
}
- (void)block3 {
[UIView animateWithDuration:0.8 delay:3.0 options:UIViewAnimationOptionCurveEaseInOut animations:^{
self.secondView.frame = self.firstView.frame;
} completion:^(BOOL finished) {
NSLog(@"options");
}];
}
4.SpringAnimation
/**
* @author Jack Lee, 16-05-16 15:05:05
*
* @brief after iOS7.0
*/
- (void)springAnimation {
// damping:取值范围0~1,值越小振荡越明显
// velocity:初始速度,越大越快
[UIView animateWithDuration:0.8 delay:0 usingSpringWithDamping:0.5 initialSpringVelocity:10 options:UIViewAnimationOptionCurveLinear animations:^{
self.secondView.frame = self.firstView.frame;
} completion:^(BOOL finished) {
NSLog(@"complete spring");
}];
}
5.关键帧动画
/**
* @author Jack Lee, 16-05-16 15:05:00
*
* @brief after iOS7.0
*/
- (void)keyFrameAnimation {
[UIView animateKeyframesWithDuration:4 delay:0 options:UIViewKeyframeAnimationOptionCalculationModeLinear animations:^{
[UIView addKeyframeWithRelativeStartTime:0 relativeDuration:1 animations:^{
self.firstView.backgroundColor = [UIColor colorWithRed:0.8 green:0.8 blue:0.8 alpha:1];
}];
[UIView addKeyframeWithRelativeStartTime:1 relativeDuration:1 animations:^{
self.firstView.backgroundColor = [UIColor colorWithRed:0.8 green:0.6 blue:0.6 alpha:1];
}];
[UIView addKeyframeWithRelativeStartTime:2 relativeDuration:1 animations:^{
self.firstView.backgroundColor = [UIColor colorWithRed:0.8 green:0.4 blue:0.4 alpha:1];
}];
[UIView addKeyframeWithRelativeStartTime:3 relativeDuration:1 animations:^{
self.firstView.backgroundColor = [UIColor colorWithRed:0.2 green:0.2 blue:0.2 alpha:1];
}];
} completion:^(BOOL finished) {
NSLog(@"complete keyframe animation");
}];
}
- Transition过渡动画二
- (void)block3 {
[UIView transitionWithView:self.firstView duration:0.8 options:UIViewAnimationOptionTransitionFlipFromLeft animations:^{
self.firstView.backgroundColor = [UIColor colorWithRed:0.2 green:0.5 blue:0.7 alpha:1];
} completion:^(BOOL finished) {
NSLog(@"complete block3");
}];
}
- (void)block4 {
UILabel *l = [[UILabel alloc] initWithFrame:self.firstView.frame];
l.font = [UIFont systemFontOfSize:30];
l.textColor = [UIColor orangeColor];
l.textAlignment = NSTextAlignmentCenter;
l.text = @"翻转";
[UIView transitionFromView:self.firstView toView:l duration:0.8 options:UIViewAnimationOptionTransitionFlipFromLeft completion:^(BOOL finished) {
NSLog(@"from to complete");
}];
}
UIKit Animation的更多相关文章
- [翻译] AFDropdownNotification
AFDropdownNotification Dropdown notification view for iOS. 下拉通知的view,用于iOS. Installation - 安装 If you ...
- UIKit,Core Data , Core Graphics, Core Animation,和OpenGLES框架
iOS的主要框架介绍 框架是一个目录,这个目录包含了共享库,访问共享库里代码的头文件,和其它的图片和声音的资源文件.一个共享库定义的方法或函数可以被应用程序调用. IOS提供了很多你可以在应用程序 ...
- Cocoa Touch(三):图形界面UIKit、Core Animation、Core Graphics
UIKit 视图树模型 1.视图树模型 计算机图形实际上是一个视图树模型,每个视图都有一个本地坐标系.每个本地坐标系的组成部分是:原点在父坐标系中的位置,每个基在父坐标系中的位置,由此就可以根据向量的 ...
- iOS UIKit:animation
@import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css); @import url(/ ...
- iOS开发之Core Animation
在IOS中如果使用普通的动画则可以使用UIKit提供的动画方式来实现,如果想实现更复杂的效果,则需要使用Core Animation了. 在Core Animation中我们经常使用的是 CABasi ...
- 老司机带你走进Core Animation
为什么时隔这么久我又回来了呢? 回来圈粉. 开玩笑的,前段时间ipv6被拒啊,超级悲剧的,前后弄了好久,然后需求啊什么的又超多,所以写好的东西也没有时间整理.不过既然我现在回来了,那么这将是一个井喷的 ...
- 响应链和UIKit框架
Event Delivery: The Responder Chain When you design your app, it’s likely that you want to respond t ...
- ios基础篇(二十五)—— Animation动画(UIView、CoreAnimation)
Animation主要分为两类: 1.UIView属性动画 2.CoreAnimation动画 一.UIView属性动画 UIKit直接将动画集成到UIView类中,实现简单动画的创建过程.UIVie ...
- 关于Core Animation(转载部分内容)
读者在浏览技术博客的时候,看到一篇关于Core Animation的介绍,觉得挺有用的,想分享给大家.原作者不知道是谁,嘿,所以就先不标注了,如有冒犯敬请原谅.不过笔者从中摘录部分内容分享一下. 其中 ...
随机推荐
- [并发编程]使用线程安全队列和条件变量的notify来安排分步骤任务
// 方法1:直接构建N个THread来run foreach (i, size) { thread trd(&Instance::doWork, &inst); lstTrd.pus ...
- CodeFirst-数据迁移-Migration
http://www.cnblogs.com/haogj/archive/2012/02/17/2356537.html 1.安装最新NuGet 2.安装EntityFramework:在程序包管理器 ...
- Ubuntu 下安装Kibana和logstash
原文地址:http://www.cnblogs.com/saintaxl/p/3946667.html 简单来讲他具体的工作流程就是 logstash agent 监控并过滤日志,将过滤后的日志内容发 ...
- linux下在多个文件夹中查找指定字符串的命令
例如,想要在当前文件夹下的多个.c或者.txt文件中查找“shutdown”字符串, 可以使用“grep shutdown ./*.c”或“grep shutdown ./*.txt”即可 使用fin ...
- Eclipse插件收藏列表
viPlugin 2.11.0 AnyEdit Tools 2.4.4 EclipseColorer 0.8.0 PyDev – Python IDE for Eclipse 2.7.5 MoreUn ...
- Java集合类操作优化经验总结
本文首先针对 Java 集合接口进行了一些介绍,并对这些接口的实现类进行详细描述,包括 LinkedList.ArrayList.Vector.Stack.Hashtable.HashMap.Weak ...
- 【转】【阮一峰的网络日志】Git 使用规范流程
作者: 阮一峰 日期: 2015年8月 5日 团队开发中,遵循一个合理.清晰的Git使用流程,是非常重要的. 否则,每个人都提交一堆杂乱无章的commit,项目很快就会变得难以协调和维护. 下面是Th ...
- 1115 HTML CSS
1. HTML 全称HyperText Markup Language (超文本标记语言). 2. 网页=HTML文件 + Web服务器 + CSS文本. 3. Web服务器:处理浏览器请求,寻找资源 ...
- hadoop2.2.0集群安装
位说明. 位).Jdk使用的1.7(1.6也可以).网络配置好,相互可以ping通,java环境安装完毕. 第一部分 Hadoop 2.2 下载 位). 下载地址:http://apache.cl ...
- java数据结构-非线性结构之树
一.树状图 树状图是一种数据结构,它是由n(n>=1)个有限节点组成的具有层次关系的集合.因其结构看起来想个倒挂的树,即根朝上,叶子在下,故被称为"树". 特点: 1. 每个 ...