添加笔划后,文字变得不可见

我有下一个问题(示例代码如下):
我使用CATextLayerNSAttributedString来显示风格化文本。 所有的工作正常,直到我添加了中风的属性。 当我添加中风 – 文字变得不可见,并在显示中,我只能看到中风。 请,我不明白会发生什么,为什么我不能同时使用文字和笔画? 谢谢。

 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]; 

您的笔画宽度必须为文字和笔画为负值,只有笔画为正值。 来自Apple Docs:

kCTStrokeWidthAttributeName 。 该属性解释为字体磅值的百分比,用于控制文本绘图模式:正值仅用于描边; 负值是中风和填充。

使用kCGTextFillStroke – 它可以同时填充和描边