현재 iOS의 UIView에서 CALayer
및 renderInContext
메소드를 사용하여 PDF 문서를 만듭니다.UIView에서 PDF를 작성하는 iOS
내가 직면 한 문제는 라벨의 선명도입니다. 내가 그렇게 같은 drawLayer
을 재정의하는 UILabel
서브 클래스 만들었습니다
/** Overriding this CALayer delegate method is the magic that allows us to draw a vector version of the label into the layer instead of the default unscalable ugly bitmap */
- (void)drawLayer:(CALayer *)layer inContext:(CGContextRef)ctx {
BOOL isPDF = !CGRectIsEmpty(UIGraphicsGetPDFContextBounds());
if (!layer.shouldRasterize && isPDF)
[self drawRect:self.bounds]; // draw unrasterized
else
[super drawLayer:layer inContext:ctx];
}
이 방법은 나에게 좋은 선명한 텍스트를 그릴 수 있습니다를, 그러나, 문제는 내가 통제권이없는 다른 전망이다. UITableView
또는 UIButton
에 포함 된 라벨에 대해 비슷한 작업을 수행 할 수있는 방법이 있습니까? 뷰 스택을 반복하고 더 선명한 텍스트를 그릴 수있는 방법을 찾는 방법을 찾고 있습니다. 이 텍스트가 잘 렌더링 (내 사용자 지정 UILabel의 서브 클래스)
가 날카로운되지 않습니다 : :
편집 여기
은 예입니다 : 다음과 같이 컨텍스트를 내 PDF로 그리는 중입니다 :UIGraphicsBeginPDFContextToData(self.pdfData, CGRectZero, nil);
pdfContext = UIGraphicsGetCurrentContext();
UIGraphicsBeginPDFPageWithInfo(CGRectMake(0, 0, 612, 792), nil);
[view.layer renderInContext:pdfContext];
가 어떻게이 상황을 '획득하는 우선이
drawLayer
방법의 내 사용자 지정 구현 카테고리UIView+PDF
을 만든 다음load
방법 나는 다음과 같은 사용 'renderInContext'를 사용하여 다시 그리는가? 거기서 해상도를 두 배로 늘릴 수 있는지 궁금합니다. – matt내 게시물이 업데이트되었습니다. – danielbeard