zoukankan      html  css  js  c++  java
  • 获得一个不错的电子书翻页效果,和大家分享

    前些天在网上搜到一个不错的电子书的翻页效果的源码,也做了个Dome,感觉很好玩,这里来和大家一起分享下.

    效果已经被写成了一个ViewController,我们只要让自己的显示界面继承这个ViewController即可.

    把我们要显示的页面保存成uiimage形式,然后实现下面这二个Delegate

    - (NSUInteger) numberOfPagesInLeavesView:(LeavesView*)leavesView {
    return 0;
    }

    - (void) renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx {

    }

    比如我想翻页显示我的一些图片,图片存以NSArray中,名字叫images吧,我可以下实现下面的Delegate就行了

    #pragma mark LeavesViewDataSource methods

    - (NSUInteger) numberOfPagesInLeavesView:(LeavesView*)leavesView {
    return [images count];
    }

    - (void) renderPageAtIndex:(NSUInteger)index inContext:(CGContextRef)ctx {
    UIImage *image = [images objectAtIndex:index];
    CGRect imageRect = CGRectMake(0, 0, image.size.width, image.size.height);
    CGAffineTransform transform = aspectFit(imageRect,
    CGContextGetClipBoundingBox(ctx));
    CGContextConcatCTM(ctx, transform);
    CGContextDrawImage(ctx, imageRect, [image CGImage]);
    }

    这样就可以实现很不错的翻页效果了!

    里面具体的实现细节大家自己看代码(见附件)吧,想怎么用大家自己发挥吧.

    有兴趣的改进下,可以实现更好的效果O(∩_∩)O~

    晕,不知道怎么上传附件,大家参考附件http://download.csdn.net/detail/zzx_evade/3811079

    (声明:资源来源于网上,版权不知道是谁的,大家各自斟酌)
    by MAC-z

  • 相关阅读:
    Axis2发布Webservice进行身份校验
    Spring集成Axis2
    分布式事务解决方案之TCC
    Lua 数据类型
    Lua 基本语法(1)
    Axis发布Webservice服务
    Linux中NFS服务器搭建
    SpringBoot多环境切换
    springboot中spring.profiles.include的妙用
    oracle树形语句
  • 原文地址:https://www.cnblogs.com/ydhliphonedev/p/2254358.html
Copyright © 2011-2022 走看看