Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- CGPDFDocumentRef PDFfile;
- CFURLRef pdfURL = CFBundleCopyResourceURL(CFBundleGetMainBundle(), CFSTR("iPhoneAppProgrammingGuide.pdf"), NULL, NULL);
- PDFfile = CGPDFDocumentCreateWithURL((CFURLRef)pdfURL);
- CFRelease(pdfURL);
- -(void)drawRect:(CGRect)rect
- {
- {
- totalpagenumpers=CGPDFDocumentGetNumberOfPages(PDFfile);
- navBar.title = [NSString stringWithFormat:@"(%d/%d)",currentpage,totalpagenumpers];
- CGPDFPageRef page = CGPDFDocumentGetPage(PDFfile,currentpage);
- context = UIGraphicsGetCurrentContext();
- CGContextSaveGState(context);
- CGContextSetRGBFillColor(context, 1.0, 1.0, 1.0, 1.0);
- CGContextFillRect(context,self.bounds);
- CGContextTranslateCTM(context, -1.0, [self bounds].size.height);
- CGContextScaleCTM(context, 1.0, -1.0);
- CGContextConcatCTM(context, CGPDFPageGetDrawingTransform(page, kCGPDFArtBox, [self bounds], 0, true));
- CGContextDrawPDFPage(context, page);
- CGContextRestoreGState(context);
- CGAffineTransform transform = aspectFit(CGPDFPageGetBoxRect(page, kCGPDFMediaBox),
- CGContextGetClipBoundingBox(context));
- CGContextConcatCTM(context, transform);
- UIGraphicsBeginImageContext(CGSizeMake(self.bounds.size.width, self.bounds.size.height));
- }
- }
- -(void)Next
- {
- size_t pageCount = CGPDFDocumentGetNumberOfPages(PDFfile);
- if (currentpage == pageCount)
- {
- NSLog(@"aaaaa");
- }
- else
- {
- [UIView beginAnimations:nil context:NULL];
- [UIView setAnimationDuration:1.0];
- [UIView setAnimationTransition:UIViewAnimationTransitionCurlUp forView:self cache:YES];
- [UIView commitAnimations];
- currentpage++;
- [self setNeedsDisplay];
- }
- }
- -(void)Previous
- {
- if (currentpage == 1||currentpage<1)
- {
- {
- NSLog(@"11111");
- }
- }
- else
- {
- [UIView beginAnimations:nil context:NULL];
- [UIView setAnimationDuration:1.0];
- [UIView setAnimationTransition:UIViewAnimationTransitionCurlDown forView:self cache:YES];
- // self.modalTransitionStyle = UIModalTransitionStylePartialCurl;
- [UIView commitAnimations];
- currentpage--;
- [self setNeedsDisplay];
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement