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