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的介绍,觉得挺有用的,想分享给大家.原作者不知道是谁,嘿,所以就先不标注了,如有冒犯敬请原谅.不过笔者从中摘录部分内容分享一下. 其中 ...
随机推荐
- SQL 判断字段中指定字符出现的次数
原文地址:SQL 判断字段中指定字符出现的次数 原理:将指定字符转换为空,原长度减去转换后的长度就是指定字符的次数. 在做数据处理时遇到一个SQL操作的问题就是有一列关键词字段,字段中包含各种乱七八糟 ...
- 【原】现有市场上H264 IPCamerad的功能
网络: 1.内置Web Server,通过IE实现远程监看.控制.设置等操作: 2.支持UPnP路由器,自动配置端口映射: 3.支持DDNS(动态域名解析).PPPoE拨号.DHCP网络协议: 4.支 ...
- 经典算法面试题目-翻转一个C风格的字符串(1.2)
题目: Write code to reverse a C-Style String. (C-String means that "abcd" is represented as ...
- sqrt (x) 牛顿迭代法
参考: 0开方 是 0 1的开方式 1 2的开方式 1.4 3.的开方=(1.4+3/1.4)/2 牛顿迭代法:学习自 http://blog.csdn.net/youwuwei2012/articl ...
- python爬虫学习(2)__抓取糗百段子,与存入mysql数据库
import pymysql import requests from bs4 import BeautifulSoup#pymysql链接数据库 conn=pymysql.connect(host= ...
- 制作静态库文件(.a文件)
制作静态库文件(.a文件) 1.创建静态库工程: 在Xcode中new一个新的project,选择IOS下面的Framework&Library,下面有一个Cocoa Touch Static ...
- js select级联,上面分类,下面是内容
js select级联,上面分类,下面是内容. js级联效果如下: 分类: 请选择 水果 蔬菜 其他 内容: // html和js代码如下: <html> <hea ...
- (转)关闭WordPress自动加载的Open Sans字体,总是连接googleapi.com,导致打开wordpress很慢
转自http://www.xuanfengge.com/turn-off-automatic-loading-wordpress-open-sans-fonts.html 一.'在网上搜了一番,有四种 ...
- EPPlus与Excel完美的结合
本文转载:http://www.cnblogs.com/olartan/archive/2012/07/14/2591711.html 笔者近期在公司项目中需要生产比较复杂的Excel报表, 问题点是 ...
- hdu 1247 Hat’s Words(字典树)
Hat's Words Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others) Tota ...