Get a good e-book page turning effect and share it with you.

Source: Internet
Author: User

 

I found a good source code for the page turning effect of an e-book on the Internet a few days ago, and made a dome. It feels very interesting. I 'd like to share it with you here.

The effect has been written as a viewcontroller. We only need to let our display interface inherit this viewcontroller.

Save the page we want to display as uiimage, and then implement the following two delegate

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

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

}

For example, I want to display some of my images on pages. The images are saved in nsarray and the name is images. I can implement the following 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]);
}

In this way, we can achieve a very good page flip effect!

You can view the code for specific implementation details (see the attachment.

If you are interested in improvement, you can achieve better results o (∩ _ ∩) O ~

 

Dizzy, do not know how to upload attachments, we refer to the attachment http://download.csdn.net/detail/zzx_evade/3811079

(Statement: resources come from the Internet, and the Copyright does not know who the resources belong to. You should consider them separately)
By Mac-z

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.