ピンチでズームインおよびズームアウトする機能が好きなので、UIWebView
ではなくコンテンツを描画しようとしています。これが私のコードです:UIView
UIWebView
// setup environment
CGRect outputRect = myWebView.bounds;
CFMutableDataRef data = CFDataCreateMutable(NULL, 0); // init with default allocator and unlimited size
CGDataConsumerRef dataConsumer = CGDataConsumerCreateWithCFData(data);
CGContextRef pdfContext = CGPDFContextCreate(dataConsumer, &outputRect, NULL);
CGPDFContextBeginPage(pdfContext, NULL);
// draw something
CGContextSetRGBFillColor (pdfContext, 1, 0, 0, 1);
CGContextFillRect (pdfContext, CGRectMake (0, 0, 200, 100 ));
CGContextSetRGBFillColor (pdfContext, 0, 0, 1, .5);
CGContextFillRect (pdfContext, CGRectMake (0, 0, 100, 200 ));
CGPDFContextEndPage(pdfContext);
// load drawing in webView
[myWebView loadData:(NSData *)data MIMEType:@"application/pdf" textEncodingName:@"utf-8" baseURL:nil];
// cleanup
if(data != NULL) CFRelease(data); // always make sure to not pass NULL in CFRelease
CGDataConsumerRelease(dataConsumer);
CGContextRelease(pdfContext);
UIWebView
目に見えるようにしたい他のことが起こっているので、次のようにの背景UIWebView
を透明にしました。
myWebView.opaque = NO; //otherwise setting background color has no effect
myWebView.backgroundColor = [UIColor clearColor];
PDFをロードしない場合、これは正しく機能します。ただし、PDFが読み込まれると、下のスクリーンショットのように、ページの背景が白になり、影が表示されます。これは私のUIデザインを台無しにしています。どうすれば影を取り除き、PDFページを透明にすることができますか?
ありがとう