博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
ibooks 3d 翻转效果 flip 3d
阅读量:5740 次
发布时间:2019-06-18

本文共 3102 字,大约阅读时间需要 10 分钟。

The iPhone has a set of nice transition animations which makes the experience using it very pleasant. But after a while one get so used of them that one stop noticing that they are even there. But this is not necessary a bad thing. Often I think that really good things doesn’t show at all, they don’t get in the way. In 3D application really good things make the experience so natural that one afterwards can wonder what the big deal was, really impressive 3D isn’t at all impressive. But, this is not about not noticing. After a while one maybe want to make that little extra in an iPhone app ie making a view transition more natural for the app. Some ebook readers have made page turning transitions.

I have for some time had the notion how to implement it, but as always,  So, this weekend I set out to make a reusable class for a OpenGL ES based view transition animation.

My idea was basically as following

  • Make a screen shot of the current view
  • Create a texture of the screen shot
  • Create a view with an OpenGL ES context, make it opaque=NO
  • Make it reusable with a delegate protocol for animation parts

Said and done. So how did this work? I’d say it worked pretty good. Maybe there is better ways to go from screen shot to texture but the well used screen grabbing code is solid.

UIGraphicsBeginImageContext(view.bounds.size); [view.layer renderInContext:UIGraphicsGetCurrentContext()]; UIImage *image = UIGraphicsGetImageFromCurrentImageContext(); UIGraphicsEndImageContext();

utility should be valued by how easy it is used. Too often I see OOP programmers making no effort at simplify a framework. Read about . So how much has to be done to use this transition view? It boils down to two parts, the actual animation and the integration into Cocoa touch views. The actual animation calls are what they are, but I separated it into two delegate methods, setupTransition and drawTransitionFrame. Then creating the objects and make use of them can look like this (from the demo project using the Utility Application Xcode template).

- (IBAction)showInfo {
        FlipsideViewController *controller = [[FlipsideViewController alloc]                                           initWithNibName:@"FlipsideView"                                           bundle:nil];     controller.delegate = self;     // Create animation delegate     DemoTransition *transition = [[[DemoTransition alloc] init] autorelease];     // Create animation view and feed the delegate     EPGLTransitionView *glview = [[[EPGLTransitionView alloc]                                    initWithView:self.view                                    delegate:transition] autorelease];     [glview startTransition];     // Animation will be run on top off next view     [self presentModalViewController:controller animated:NO];     [controller release]; }

Update: Added features to include transition into next view, grabbing next view as a texture and making it available for the drawTransitionFrame method

Grab the source code and a Xcode demo project at 

转载于:https://www.cnblogs.com/zhuolaiqiang/archive/2011/06/29/2123770.html

你可能感兴趣的文章
Redis笔记系列(一)——Redis精要介绍与适用场景
查看>>
java 连接MySql数据库
查看>>
架构设计:一种远程调用服务的设计构思(zookeeper的一种应用实践)
查看>>
Linux 系统病毒入侵分析
查看>>
文件操作(File)
查看>>
MySQL 常用函数详解
查看>>
Tomcat部署Web应用方法总结
查看>>
Spring Security 文档翻译 - 架构与实现之二核心服务
查看>>
解决[Errno 24] Too many open files
查看>>
Android之parseSDKContent failed
查看>>
docker nginx安装
查看>>
ntdll 里面的 DbgPrint
查看>>
给SVN泼盆冷水,是时候用GIT了
查看>>
ubuntu 14.04 NTP服务器搭建及某些故障排查
查看>>
netty 源码编译搭建
查看>>
openstack swift构建公有云
查看>>
JVM调优总结 -Xms -Xmx -Xmn -Xss
查看>>
在Linux下如何使用GCC编译程序、简单生成静态库及动态库。
查看>>
JQuery中阻止事件冒泡方式及其区别
查看>>
久坐是科技时代的“香烟”
查看>>