之前受某人影响以为一连串的UIView Animation 只能这么写:

在某个animation 设置delegate ,然后在 delegate 函数中再调用另一个函数。

今天偷闲决定看 iPhone cookbook 代码查漏补缺下,结果发现这代码:

C代码
// Hide the bar button and show the view
self.navigationItem.rightBarButtonItem = nil;
[self.view viewWithTag:101].alpha = 1.0f;

// Bounce to 115% of the normal size
[UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.4f];
[self.view viewWithTag:101].transform = CGAffineTransformMakeScale(1.15f, 1.15f);
[UIView commitModalAnimations];

// Return back to 100%
[UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:0.3f];
[self.view viewWithTag:101].transform = CGAffineTransformMakeScale(1.0f, 1.0f);
[UIView commitModalAnimations];

// Pause for a second and appreciate the presentation
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0f]];

// Slowly zoom back down and hide the view
[UIView beginAnimations:nil context:UIGraphicsGetCurrentContext()];
[UIView setAnimationCurve:UIViewAnimationCurveEaseInOut];
[UIView setAnimationDuration:1.0f];
[self.view viewWithTag:101].transform = CGAffineTransformMakeScale(0.01f, 0.01f);
[UIView commitModalAnimations];

// Restore the bar button
[self.view viewWithTag:101].alpha = 0.0f;

tnnd 原来可以这么写。

同时学到个新玩意。

C代码
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0f]];

PS. 原来这个例子就叫做 Modal View Animation 罪过罪过,搞了这么久iPhone还不知道这东西。

####################################################

#### 抱歉,看错了,原来是作者自己实现的方法 ########

####################################################

仔细一看原来

C代码
commitModalAnimations

具体代码实现是这样的。
Java代码
@interface UIViewDelegate : NSObject
{
CFRunLoopRef currentLoop;
}
@end

@implementation UIViewDelegate
-(id) initWithRunLoop: (CFRunLoopRef)runLoop
{
if (self = [super init]) currentLoop = runLoop;
return self;
}

-(void) animationFinished: (id) sender
{
CFRunLoopStop(currentLoop);
}
@end

@implementation UIView (ModalAnimationHelper)
+ (void) commitModalAnimations
{
CFRunLoopRef currentLoop = CFRunLoopGetCurrent();

UIViewDelegate *uivdelegate = [[UIViewDelegate alloc] initWithRunLoop:currentLoop];
[UIView setAnimationDelegate:uivdelegate];
[UIView setAnimationDidStopSelector:@selector(animationFinished:)];
[UIView commitAnimations];
CFRunLoopRun();
[uivdelegate release];
}
@end

转载于:https://blog.51cto.com/rongbaohong/785001

UIView Animation效果相关推荐

  1. UIView Animation

    作者 嘿o大远 关注 2017.03.23 17:02* 字数 402 阅读 47评论 1喜欢 3 今天总结一下UIView动画就是 UiView动画是基于高层API封装进行封装的,对UIView的属 ...

  2. UIView动画效果

    UIView是iOS系统中界面元素的基础, 所有的界面元素都是继承自它.它本身完全由CoreAnimation来实现的.它真正的绘图部分,是由一个CALayer类来管理.UIView本身更像一个CAL ...

  3. Android开发--图形图像与动画(三)--Animation效果的XML实现

    使用XML来定义Tween Animation 动画的XML文件在工程中res/anim目录,这个文件必须包含一个根元素,可以使<alpha><scale> <trans ...

  4. 动画---图形图像与动画(三)Animation效果的XML实现

    使用XML来定义Tween Animation  动画的XML文件在工程中res/anim目录,这个文件必须包含一个根元素,可以使<alpha><scale> <tran ...

  5. html渐变显示动画效果,使用CSS transition和animation改变渐变状态

    到目前为止,CSS的渐变属性linear-gradient和radial-gradient已经是很成熟的CSS特性了,而且repeating-linear-gradient和conic-gradien ...

  6. UIView及其分类的属性方法定义

    UIView是iOS开发中最熟悉的控件,不是因为它用得多,而是很多UI控件都是继承它的,了解它的分类方法是很有必要的. UIView其实是由多个分类构成,主要有如下几个分类: UIView :基本属性 ...

  7. UIViewController与UIView的关系

    haoxue 2010-11-21 21:30 iphone--UIViewController与UIView的关系 UIView翻转效果实现 新建一个view-based模板工程,在ViewCont ...

  8. iOS - UIView属性hidden, opaque, alpha, opacity的区别

    iOS开发-之UIView属性hidden, opaque, alpha, opacity的区别 一.alpha 液晶显示器是由一个个的像素点组成的,每个像素点都可以显示一个由RGBA颜色空间组成的一 ...

  9. ios uiview动画_iOS UIView动画

    ios uiview动画 In this tutorial, we'll be animating our UI Views in various ways in the iOS Applicatio ...

最新文章

  1. java ase 加密_java实现ase加密解密
  2. java 正则 反向引用_正则之反向引用
  3. 礼物——最牛午饭证!
  4. ML之RF/kNNC/LoRC/SVMC/RFC/GBDTC:利用Pipeline(客户年龄/职业/婚姻/教育/违约/余额/住房等)预测客户是否购买该银行的产品二分类(评估、调优、推理)
  5. NSIS修改开始菜单中图标
  6. eureka client客户端启动时都做了哪些事
  7. 通过异常捕获判断字符串是不是数字格式
  8. easyui edatagrid 触发编辑行回掉onEdit
  9. java中or和and的优先级_x86处理器汇编语言AND和OR运算符优先级
  10. Android 中的接口回调
  11. mysql是什么1001mysql是什么_mysql深入理解
  12. Linux中sudo免密码
  13. bilibili视频解析php源码,Bilibili视频直链信息解析工具源码
  14. Win10系统隐藏磁盘
  15. PS一键磨皮美白扩展插件Delicious Retouch 5.0 汉化集合版 Win/Mac
  16. php三级分销思路 数据库设计_三级分销,
  17. 公众号搜题怎么实现的?
  18. 深入理解Windows域概念
  19. 微信小游戏从零开始申请软著到上线
  20. git push origin HEAD

热门文章

  1. list工具类 ListUtils.java
  2. 如何安装mysql 5.6_如何安装MySQL 5.6?
  3. apch连接mysql数据库连接_配置phpmyadmin连接远程 MySQL数据库
  4. gophp解释器_go语言环境搭建、基本使用
  5. 天龙八部手游显示与服务器断开连接,天龙八部手游怎么设置 游戏设置方法(图文详解)...
  6. 浙大版python_浙大版《Python 程序设计》题目集1-5
  7. 在linux搭性能测试环境,性能测试学习第七天-----JMeter之linux环境部署篇
  8. java 1.7 可变参数,JDK1.7新特性(2):异常和可变长参数处理
  9. python文件命名 数字_python 批量修改数字类的文件名
  10. html换行符_HTML 列表