【发布时间】:2011-08-10 10:02:50
【问题描述】:
我正在尝试裁剪 UIView,然后将其转换为 pdf 文件。 UIView 正确裁剪 x 组件、宽度和高度。但它采用相同的 y 分量,即 0 进行渲染。我想从顶部裁剪图像 110 点。这是我的代码
UIView *tempV;
tempV=self.view;
CGRect fram= tempV.bounds;
fram.origin.x=537;
fram.origin.y=110;
fram.size.width=404;
fram.size.height=772;
tempV.bounds=fram;
NSLog(@"Mail");
NSLog(@"%f,%f,%f,%f",tempV.bounds.origin.x,tempV.bounds.origin.y,tempV.bounds.size.width,tempV.bounds.size.height);
NSMutableData *pdfData=[NSMutableData data];
UIGraphicsBeginPDFContextToData(pdfData, tempV.bounds, nil);
UIGraphicsBeginPDFPage();
CGContextRef pdfContext= UIGraphicsGetCurrentContext();
[tempV.layer renderInContext:pdfContext];
UIGraphicsEndPDFContext();
MFMailComposeViewController *mailComposer=[[[MFMailComposeViewController alloc]init] autorelease];
mailComposer.mailComposeDelegate=self;
[mailComposer addAttachmentData: pdfData mimeType: @"application/pdf" fileName: @"Dudel creation.pdf"];
[pdfData writeToFile:@"Dudel creation.pdf" atomically:YES];
[self presentModalViewController: mailComposer animated: YES];
【问题讨论】:
标签: objective-c ipad pdf uiview