다른 방법이있을 수 있지만,이 작업을 수행하는 한 가지 방법은 먼저 직접 이전에 그려진 어떤 솟다 만 채우기 문자열을 그릴 만 스트로크 문자열을 그릴 것입니다. Adobe InDesign에는 실제로이 내장 기능이있어 문자 외부에 획을 적용하여 가독성을 높일 수 있습니다.
이 (http://developer.apple.com/library/mac/#qa/qa2008/qa1531.html 영감)이 작업을 수행하는 방법을 단지 예시 적이다 :
:
가
@implementation MDInDesignTextView
static NSMutableDictionary *regularAttributes = nil;
static NSMutableDictionary *indesignBackgroundAttributes = nil;
static NSMutableDictionary *indesignForegroundAttributes = nil;
- (void)drawRect:(NSRect)frame {
NSString *string = @"Got stroke?";
if (regularAttributes == nil) {
regularAttributes = [[NSMutableDictionary
dictionaryWithObjectsAndKeys:
[NSFont systemFontOfSize:64.0],NSFontAttributeName,
[NSColor whiteColor],NSForegroundColorAttributeName,
[NSNumber numberWithFloat:-5.0],NSStrokeWidthAttributeName,
[NSColor blackColor],NSStrokeColorAttributeName, nil] retain];
}
if (indesignBackgroundAttributes == nil) {
indesignBackgroundAttributes = [[NSMutableDictionary
dictionaryWithObjectsAndKeys:
[NSFont systemFontOfSize:64.0],NSFontAttributeName,
[NSNumber numberWithFloat:-5.0],NSStrokeWidthAttributeName,
[NSColor blackColor],NSStrokeColorAttributeName, nil] retain];
}
if (indesignForegroundAttributes == nil) {
indesignForegroundAttributes = [[NSMutableDictionary
dictionaryWithObjectsAndKeys:
[NSFont systemFontOfSize:64.0],NSFontAttributeName,
[NSColor whiteColor],NSForegroundColorAttributeName, nil] retain];
}
[[NSColor grayColor] set];
[NSBezierPath fillRect:frame];
// draw top string
[string drawAtPoint:
NSMakePoint(frame.origin.x + 200.0, frame.origin.y + 200.0)
withAttributes:regularAttributes];
// draw bottom string in two passes
[string drawAtPoint:
NSMakePoint(frame.origin.x + 200.0, frame.origin.y + 140.0)
withAttributes:indesignBackgroundAttributes];
[string drawAtPoint:
NSMakePoint(frame.origin.x + 200.0, frame.origin.y + 140.0)
withAttributes:indesignForegroundAttributes];
}
@end
이것은 다음과 같은 출력을 생성한다 : 첫째 속성을 설정
,363,210
지금, 그것은 확실히 기본보다 더 나은 모습, 그리 때로는 소수의 경계에 떨어질 것이기 때문에, 완벽하지,하지만. 성능에 문제가있는 경우
, 당신은 항상 같은있는 CoreGraphics 또는 CoreText로, 약간 낮은 수준까지 떨어로 볼 수 있었다.
감사합니다. 치료를해라. –
위대하고 상세한 답변. 시간을 가져 주셔서 감사합니다! – epologee
간단합니다. 훌륭한. ... 그리고 완전히 불필요 할 것입니다 ... (지원은 이미 존재해야합니다) – u2Fan