次の問題があります (以下のサンプル コード):定型化されたテキストの表示を
使用CATextLayer
しています。NSAttributedString
属性にストロークを追加するまで、すべて正常に機能します。ストロークを追加すると、テキストが非表示になり、ディスプレイにストロークだけが表示されます。何が起こるのか理解できません。テキストとストロークの両方を使用できないのはなぜですか? ありがとう。
UIFont* font = [UIFont fontWithName: size:];
UIColor* strokeColor = [UIColor colorWithRed: green: blue: alpha:1.f];
UIColor* foregroundColor = [UIColor colorWithRed: green: blue: alpha:1.f];
CTFontDescriptorRef fontDescriptor = CTFontDescriptorCreateWithNameAndSize(...);
CTFontRef ctFont = CTFontCreateWithFontDescriptor(...);
NSDictionary* attributes = [NSDictionary dictionaryWithObjectsAndKeys:
strokeWidth, kCTStrokeWidthAttributeName,
[strokeColor CGColor], kCTStrokeColorAttributeName,
ctFont, kCTFontAttributeName,
[foregroundColor CGColor], kCTForegroundColorAttributeName,
nil];
NSAttributedString* attributedText =
[[NSAttributedString alloc] initWithString:text attributes:attributes];
CATextLayer* infoTextLayer = [[[CATextLayer alloc] init] autorelease];
infoTextLayer.string = attributedText;
...
infoTextLayer.frame = frame;
[self.layer addSublayer:infoTextLayer];