Core Text的First-Line-Indent设置在iPhone5s / 6中不起作用

时间:2015-02-12 10:08:37

标签: ios core-text

[update]最后,我发现问题在4s / 5和5s / 6之间。 在5s / 6模拟器和真实手机中没有任何第一行缩进。 iOS版本是8.2。

缩进设置在8.1.2(5c)iPhone和模拟器中运行良好,但在我的ip6和另外5s(均为8.1.3)中没有任何第一行缩进。

见截图:

enter image description here

任何人遇到同样的问题?

// indent
    CTParagraphStyleSetting indentSetting;
    indentSetting.spec = kCTParagraphStyleSpecifierFirstLineHeadIndent;
    indentSetting.value = &indent;
    indentSetting.valueSize = sizeof(float);

    CTParagraphStyleSetting settings[] = {lineBreakMode,paragraphSpacing,LineSpacing,alignmentSetting,indentSetting};
    CTParagraphStyleRef paragraphStyle = CTParagraphStyleCreate(settings, 5);   //第二个参数为settings的长度

    textStyle = [NSDictionary dictionaryWithObjectsAndKeys:
            (id)fontColor.CGColor, kCTForegroundColorAttributeName,
            fontRef, kCTFontAttributeName,
            kernRef,kCTKernAttributeName,
            paragraphStyle,kCTParagraphStyleAttributeName,
            nil]

    attString=[[NSMutableAttributedString alloc] initWithString:text attributes:textStyle]; //1

    CTFramesetterRef framesetter =
    CTFramesetterCreateWithAttributedString((CFAttributedStringRef)attString); //3

    CTFrameRef frame =
    CTFramesetterCreateFrame(framesetter,
                             CFRangeMake(0, [attString length]), path, NULL);
    
    CTFrameDraw(frame, context); //4

0 个答案:

没有答案