http://mobile.51cto.com/iphone-285320.htm
iPhone开发中关于UIView Animation实现效果是本文要介绍的内容,主要是来学习UIView Animation一连串的实现效果,具体内容我们来看本文如何实现。之前受某人影响以为一连串的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
小结:iPhone开发中关于UIView Animation实现效果的内容介绍完了,希望通过本文的学习能对你有所帮助!
分享到:
相关推荐
用animation实现UIView动画效果,简单上中下移动
ios中关于uiview
6个UIView的弹簧效果布局,添加点击实现
自定义 UIView的阴影效果自定义 UIView的阴影效果
ShadowView 让你能够轻松在UIView上实现阴影效果
已封装好的实现渐变的UIView,只需传入渐变开始值和结束值就可直接使用。有四种渐变方向可选
这是一个ios动画开发的demo(请在github上获取最新代码),内容有 -uiview动画 -CoreAnimation基本动画 -关键帧动画 -TransferAnimation 文章对应的开发说明 ...
UIView 震动动画效果 AFViewShaker ,AFViewShaker 是一个简单的工具用来执行 。 使用方法: AFViewShaker *...
Twinkle - ✨一个Swift和简单的方法能让任何UIView产生闪烁效果
自己写了一个Dome 实现了UIView或者时UIViewController 缩放动画效果
uiView 动画翻转的效果,显示前后两个视图替换显示
UIAnimation 此类提供了使用UIView组件轻松实现动画的方法与SpriteKit的SKAction的SKNode , UIAnimation表示可以在UIView上运行的动作。 有了它,您可以移动,旋转和创建动作和块序列。 可以存储动画并在多个视图中...
UIView切换效果集 HMGLTransitions ,HMGLTransitions 实现了一组不同的 UIView 之间切换效果的功能。
为UIView添加弹簧效果,并设置显示文本内容和弹出次数
UIView 动画 UIView动画
iOS中UIView的翻页动画demo 有几个是私有的api,小心使用。
NULL 博文链接:https://913.iteye.com/blog/1356151
支持 CocoaPods! pod 'LCBlur' GitHub:https://github.com/iTofu/LCBlur 请在 GitHub 上查阅,以保证版本最新! 有问题请移步 GitHub!...(之前发过一次,效果没讲清楚,貌似不能编辑,重新发下哈!)
UIView AutoLayout ,UIView AutoLayout 是 UIView 的分类,实现了自动布局限制的简单接口。 T...
这是一种实现 UIView 镂空效果的方案,可以快速实现任意形状的镂空、文字的镂空、带镂空的毛玻璃效果等。本质上是 UIView 的 maskView 效果。 前言 首先来复习一下遮罩效果的实现。如果我们有一张图片,又恰好有一个...