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的介绍,觉得挺有用的,想分享给大家.原作者不知道是谁,嘿,所以就先不标注了,如有冒犯敬请原谅.不过笔者从中摘录部分内容分享一下. 其中 ...
随机推荐
- HDU-2975 Billboard
Billboard Time Limit : 20000/8000ms (Java/Other) Memory Limit : 32768/32768K (Java/Other) Total Su ...
- RobotFramework+Selenium2library+Appium+Python+RIDE安装指南
最近在测试APP+WEB,想找一个好的自动化测试工具.然后发现RIDE这工具,框架比较自由,支持中文,有测试报告. 一个好的自动化测试就应该包含:Case管理+脚本的编写+自动生产报告. 如此一想,这 ...
- PowerDesigner 如何生成数据库更新脚本
最近在学习使用PowerDesigner 这个数据库设计工具,发现真的很强大,可以做很多事情,其中就涉及到如果数据库要进行更新了怎么办,主要是增加表,最麻烦的是修改字段名称,增加字段等操作,遇到主要的 ...
- c++通过jnihelper调用java方法刷新androidUI的注意事项
2dx android项目需接入第三方sdk完成支付,玩家点击充值界面,通过jnihelper来调用java的方法并弹出android组件界面,之前采用直调的简单方法,顺利的把参数传到java层,但后 ...
- [App]Android Studio First App
准备着看Android Studio的体验如何. 通过Android Studio构建一个默认的项目,添加一些元素 <RelativeLayout xmlns:android="htt ...
- Git起步--git安装与初次运行git前配置
在你开始使用 Git 前,需要将它安装在你的计算机上. 即便已经安装,最好将它升级到最新的版本. 你可以通过软件包或者其它安装程序来安装,或者下载源码编译安装. 一.Git安装 1. 在linux上安 ...
- [洛谷U990]传递游戏(90分)
[题目描述 Description] n个人在做传递物品的游戏,编号为1-n. 游戏规则是这样的:开始时物品可以在任意一人手上,他可把物品传递给其他人中的任意一位:下一个人可以传递给未接过物品的任意一 ...
- ubuntu Server LAmp环境
1. LAMP 的安装 sudo apt-get install apache2 mysql-server mysql-client php5 php5-gd php5-mysql 由于LAMP大部分 ...
- Spark RDD/Core 编程 API入门系列之动手实战和调试Spark文件操作、动手实战操作搜狗日志文件、搜狗日志文件深入实战(二)
1.动手实战和调试Spark文件操作 这里,我以指定executor-memory参数的方式,启动spark-shell. 启动hadoop集群 spark@SparkSingleNode:/usr/ ...
- Apache Commons 工具类
http://blog.csdn.net/feicongcong/article/details/53374399http://blog.csdn.net/hsienhua/article/detai ...