2014-04-06 1 views
0

iOS 7.1로 프로젝트를 만들 때까지 잘 작동하는 코드가 있습니다. 이전에는 텍스트가 PDF 페이지에 올바르게 표시되었습니다.iOS 7.1 NSString drawInRect

[strSomeText drawInRect:rectForText withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, mutParagraphStyle, NSParagraphStyleAttributeName, colorRed, NSForegroundColorAttributeName, nil]]; 

하지만 지금은 서식 사전의 모든 내용이 무시됩니다. PDF 문서에는 기본 글꼴 및 크기의 검은 텍스트가 표시됩니다.

감사합니다.

답변

0

나는 NSAttributedString을 사용하고 이것이 작동하는지 확인하려고합니다. 난 당신의 코드가 작동이 중지되었습니다 이유에 좋은 이유가 있지만,이 시도하지 않습니다

// obviously these variables are examples, keep whatever variables you are using 
UIFont *font = [UIFont fontWithName:@"whatever_font" size:16.0f]; 
NSParagraphStyle *paragraphStyle = [NSParagraphStyle defaultParagraphStyle]; 

NSDictionary *attributes = @{NSFontAttributeName : font, NSParagraphStyleAttributeName : paragraphStyle, NSForegroundColorAttributeName : [UIColor redColor]}; 

NSAttributedString *attributedString = [[NSAttributedString alloc] initWithString:exampleString attributes:attributes]; 

[attributedString drawInRect]; 
+0

감사합니다,하지만 불행히도, 결과는 동일합니다 . 이상하다. –

0

당신이 시도 할 수 있습니다 : 제안을

UIGraphicsPushContext(ctx); 

[strSomeText drawInRect:rectForText withAttributes:[NSDictionary dictionaryWithObjectsAndKeys:font, NSFontAttributeName, mutParagraphStyle, NSParagraphStyleAttributeName, colorRed, NSForegroundColorAttributeName, nil]]; 

UIGraphicsPopContext(); 
+0

길었고 코드를 보면 나는 차이점을 보지 못했지만 컨텍스트를 푸는 것은 해결책의 일부가 아니 었습니다. 어쨌든, 귀하의 회신에 감사드립니다. –