之前受某人影响以为一连串的UIView Animation 只能这么写:
在某个animation 设置delegate ,然后在 delegate 函数中再调用另一个函数。
今天偷闲决定看 iPhone cookbook 代码查漏补缺下,结果发现这代码:
// 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 原来可以这么写。
同时学到个新玩意。
[NSThread sleepUntilDate:[NSDate dateWithTimeIntervalSinceNow:1.0f]];
PS. 原来这个例子就叫做 Modal View Animation 罪过罪过,搞了这么久iPhone还不知道这东西。
####################################################
#### 抱歉,看错了,原来是作者自己实现的方法 ########
####################################################
仔细一看原来
commitModalAnimations
具体代码实现是这样的。
@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
分享到:
相关推荐
-uiview动画 -CoreAnimation基本动画 -关键帧动画 -TransferAnimation 文章对应的开发说明 http://liuyanwei.jumppo.com/2015/10/30/iOS-Animation-UIViewAndCoreAnimation.html 如果大家支持,请在github...
UIView 动画 UIView动画
ios中关于uiview
UIView+Extension 对view的一个扩展
UIView AutoLayout ,UIView AutoLayout 是 UIView 的分类,实现了自动布局限制的简单接口。 T...
简单的把UIView转化为UIImage,大家可以看下。
ImageFreeCut, 使用UIView子类可以在图像上绘制路径,并将该部分裁剪为 ImageFreeCut使用UIView子类可以在图像上绘制路径,并将该部分裁剪为。演示 尝试pod try ImageFreeCut要求Xcode 8 快速 3 iOS 10 安装use_
用animation实现UIView动画效果,简单上中下移动
1、将UIView 保存为图片,按照给定的scale 2、stackoverflow参照 3、保存的图片为依据scale,亲测
详细讲解UIView的生命循环周期,对开发者有更好的启发作用,深层次了解程序运行的流程。
+ (UIView *_Nullable)az_gradientViewWithColors:(NSArray*> *_Nullable)colors locations:(NSArray*> *_Nullable)locations startPoint:(CGPoint)startPoint endPoint:(CGPoint)endPoint; - (void)az_...
为UIView添加圆角扩展
UIAnimation 此类提供了使用UIView组件轻松实现动画的方法与SpriteKit的SKAction的SKNode , UIAnimation表示可以在UIView上运行的动作。 有了它,您可以移动,旋转和创建动作和块序列。 可以存储动画并在多个视图中...
已封装好的实现渐变的UIView,只需传入渐变开始值和结束值就可直接使用。有四种渐变方向可选
UIView-Positioning, 在UIView对象中,基于简单属性的框架属性设置 uiview定位收费 UIView Positioning 是一个快速扩展,它提供简单的shorthand 方法,以方便的方式定义任何UIView对象的框架属性( 宽度,高度,x,y ...
NULL 博文链接:https://zhangmingwei.iteye.com/blog/1948108
iOS中UIView的翻页动画demo 有几个是私有的api,小心使用。
iOS中对UIView类的扩展,可以方便的获取到控件的各种尺寸。
通过协议扩展高斯模糊任意 UIView.zip,对任何具有swift协议扩展的uiview应用高斯模糊
iPhone开发学习笔记005——使用XIB自定义一个UIView,然后将这个view添加到controller的view。