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];
}
  1. 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");
}];
}
  1. 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的更多相关文章

  1. [翻译] AFDropdownNotification

    AFDropdownNotification Dropdown notification view for iOS. 下拉通知的view,用于iOS. Installation - 安装 If you ...

  2. UIKit,Core Data , Core Graphics, Core Animation,和OpenGLES框架

    iOS的主要框架介绍   框架是一个目录,这个目录包含了共享库,访问共享库里代码的头文件,和其它的图片和声音的资源文件.一个共享库定义的方法或函数可以被应用程序调用. IOS提供了很多你可以在应用程序 ...

  3. Cocoa Touch(三):图形界面UIKit、Core Animation、Core Graphics

    UIKit 视图树模型 1.视图树模型 计算机图形实际上是一个视图树模型,每个视图都有一个本地坐标系.每个本地坐标系的组成部分是:原点在父坐标系中的位置,每个基在父坐标系中的位置,由此就可以根据向量的 ...

  4. iOS UIKit:animation

    @import url(http://i.cnblogs.com/Load.ashx?type=style&file=SyntaxHighlighter.css); @import url(/ ...

  5. iOS开发之Core Animation

    在IOS中如果使用普通的动画则可以使用UIKit提供的动画方式来实现,如果想实现更复杂的效果,则需要使用Core Animation了. 在Core Animation中我们经常使用的是 CABasi ...

  6. 老司机带你走进Core Animation

    为什么时隔这么久我又回来了呢? 回来圈粉. 开玩笑的,前段时间ipv6被拒啊,超级悲剧的,前后弄了好久,然后需求啊什么的又超多,所以写好的东西也没有时间整理.不过既然我现在回来了,那么这将是一个井喷的 ...

  7. 响应链和UIKit框架

    Event Delivery: The Responder Chain When you design your app, it’s likely that you want to respond t ...

  8. ios基础篇(二十五)—— Animation动画(UIView、CoreAnimation)

    Animation主要分为两类: 1.UIView属性动画 2.CoreAnimation动画 一.UIView属性动画 UIKit直接将动画集成到UIView类中,实现简单动画的创建过程.UIVie ...

  9. 关于Core Animation(转载部分内容)

    读者在浏览技术博客的时候,看到一篇关于Core Animation的介绍,觉得挺有用的,想分享给大家.原作者不知道是谁,嘿,所以就先不标注了,如有冒犯敬请原谅.不过笔者从中摘录部分内容分享一下. 其中 ...

随机推荐

  1. (转载)C++ const成员初始化问题

    (转载)http://www.189works.com/article-45135-1.html Const成员如其它任何成员一样,简单考虑其出现在三个位置:全局作用域.普通函数内部.类里面. 下面请 ...

  2. Tag file directory /struts-tags does not start with "/WEB-INF/tags"

    使用自定义标签,记得引用路径 <%@taglib prefix="s" uri="/struts-tags" %>

  3. JavaScript高级程序设计33.pdf

    操作样式表 CSSStyleSheet类型表示的是样式表包括通过<link>元素包含的样式表和在<style>元素中定义的样式表,前面提到过这两个元素本身分别是由HTMLLin ...

  4. Dijkstra算法求解最短路径分析

    最短路径是图论算法中的经典问题.图分为有向图.无向图,路径权值有正值.负值,针对不同的情况需要分别选用不同的算法.在维基上面给出了各种不同的场景应用不同的算法的基本原则:最短路问题. 针对无向图,正权 ...

  5. DirectShow Filter 开发典型例子分析 ——字幕叠加 (FilterTitleOverlay)1

    本文分析一下<DirectShow开发指南>中的一个典型的Transform Filter的例子:字幕叠加(FilterTitleOverlay).通过分析该例子,我们可以学习到Direc ...

  6. oc学习之路----内存管理

    直接上图啊.

  7. VirtualBox安装Ghost XP

    http://jingyan.baidu.com/album/5d368d1e1a88b73f60c05721.html?picindex=1

  8. selenuim +python环境配置遇到的诸多问题

    自动化测试入门,总结一下安装selenium.python以及配置webdriver遇到的问题: 准备工作: 1.下载火狐浏览器并安装插件selenium IDE.Firebug~~ 2.下载安装py ...

  9. maven项目文件乱码问题

    今日碰到maven项目中的一个资源文件出现乱码,排查发现是在.setting文件夹下的org.eclipse.core.resources.prefs文件导致的. 修改前的编码规则如下: <sp ...

  10. swift小结01--基础篇

    2014年推出的swift目前已来到了3.0,日趋稳定,这个是之前学习整理的关于swift的资料,分享给大家,希望有用,写的不足的地方还请见谅. 语言背景:         Swift 语言由苹果公司 ...