Ipad 如何使用coreText控制粗体字符串

Ipad 如何使用coreText控制粗体字符串,ipad,core-text,nsattributedstring,Ipad,Core Text,Nsattributedstring,我用上面的代码设置了kCTStrokeWidthAttributeName,但它仍然是粗体的 我不想让绳子变粗 如何控制它???签出kCTFontWeightTrait和kCTFontBoldTrait。尝试将宽度值更改为: 删除粗体文本 来自苹果的文档: kCTStrokeWidthAttributeName 笔划宽度。值必须是CFNumberRef对象。默认值为0.0,或无笔划。此属性,解释为 字体点大小的百分比,控制文本绘制模式: 正值仅影响带有笔划的绘图;负值是 用于笔划和填充。轮廓文本

我用上面的代码设置了kCTStrokeWidthAttributeName,但它仍然是粗体的

我不想让绳子变粗

如何控制它???

签出kCTFontWeightTrait和kCTFontBoldTrait。

尝试将宽度值更改为:

删除粗体文本

来自苹果的文档:

kCTStrokeWidthAttributeName 笔划宽度。值必须是CFNumberRef对象。默认值为0.0,或无笔划。此属性,解释为 字体点大小的百分比,控制文本绘制模式: 正值仅影响带有笔划的绘图;负值是 用于笔划和填充。轮廓文本的典型值为3.0


@MarkLinus实际上是这样的,kCTStrokeWidthAttributeName属性是控制文本粗体的方式,在这里,他将他的widthValue设置为-1,这会增加文本的胆量。我补充了澄清。
CGFloat widthValue = -1.0;

CFNumberRef strokeWidth = CFNumberCreate(NULL,kCFNumberFloatType,&widthValue);

//Setup the attributes dictionary with font and color
NSDictionary *attributes = [NSDictionary dictionaryWithObjectsAndKeys:
                            (id)font, (id)kCTFontAttributeName,
                            _fontColor.CGColor, kCTForegroundColorAttributeName,
                            strokeWidth,kCTStrokeWidthAttributeName,
                            nil];
CGFloat widthValue = 0.f;