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

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

我不希望字符串变粗。

我怎么能控制它????

4

2 回答 2

0

Try changing your widthValue to:

CGFloat widthValue = 0.f;

to remove the bold text.

From Apple's docs:

kCTStrokeWidthAttributeName The stroke width. Value must be a CFNumberRef object. Default value is 0.0, or no stroke. This attribute, interpreted as a percentage of font point size, controls the text drawing mode: positive values effect drawing with stroke only; negative values are for stroke and fill. A typical value for outlined text is 3.0.

于 2013-04-08T22:03:03.117 回答
0

结帐kCTFontWeightTraitkCTFontBoldTrait.

于 2012-05-11T04:02:37.587 回答