NSAttributedString kCTParagraphStyleSpecifierParagraphSpacing无效
|
当应用kCTParagraphStyleSpecifierParagraphSpacing样式时,它对呈现的文本没有视觉效果。其他属性,例如行距和文本对齐方式,效果很好。我可能做错了什么?
CTTextAlignment theAlignment = kCTRightTextAlignment;
CGFloat paragraphSpacingFloat = 150.0;
CGFloat paragraphSpacingBeforeFloat = 150.0;
CGFloat lineSpacing = CTFontGetLeading(baseFont)*5.0;
CFIndex theNumberOfSettings = 4;
CTParagraphStyleSetting theSettings[4] = {
{ kCTParagraphStyleSpecifierParagraphSpacing, sizeof(CGFloat), ¶graphSpacingFloat },
{ kCTParagraphStyleSpecifierParagraphSpacingBefore, sizeof(CGFloat), ¶graphSpacingBeforeFloat },
{ kCTParagraphStyleSpecifierAlignment, sizeof(CTTextAlignment), &theAlignment },
{ kCTParagraphStyleSpecifierLineSpacing, sizeof(CGFloat), &lineSpacing }
};
CTParagraphStyleRef theParagraphRef = CTParagraphStyleCreate(theSettings, theNumberOfSettings);
[attr addAttribute:(id)kCTParagraphStyleAttributeName value:(id)theParagraphRef range:r];
[attr addAttribute:(id)kCTFontAttributeName value:(id)baseFont range:r];
CFRelease(theParagraphRef);
我使用渲染文本
CTFrameSetter frameSetter = CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attr);
CTFrameRef frame = CTFramesetterCreateFrame(frameSetter, CFRangeMake([[attr string] length], 0), the_drawing_cgrect, NULL);
CTFrameDraw(frame, context);
没有找到相关结果
已邀请:
2 个回复
联海
街茬