爱程序网

CoreText 关键性常用函数说明

来源: 阅读:

CoreText类真的太强大了,不服不行。

 

1.这个函数用来处理行宽不一致的问题,有些行的由于内部有一些标点符号,无法占满整行,导致行宽参差不齐,这个函数专门处理这个问题。

CTLineRef __nullable CTLineCreateJustifiedLine(

    CTLineRef line,

    CGFloat justificationFactor,

    double justificationWidth ) CT_AVAILABLE(10_5, 3_2);

 

2. 获取行中间某一个索引位置的字符的x坐标

CGFloat CTLineGetOffsetForStringIndex(

    CTLineRef line,

    CFIndex charIndex,

    CGFloat * __nullable secondaryOffset ) CT_AVAILABLE(10_5, 3_2);

 

3.根据一个点的坐标位置获取在这个行中字符位置的索引

CFIndex CTLineGetStringIndexForPosition(

    CTLineRef line,

    CGPoint position ) CT_AVAILABLE(10_5, 3_2);

 

 

4.获取行的一些信息,其中返回值为行的整体宽度,行的高度为ascent+descent

double CTLineGetTypographicBounds(

    CTLineRef line,

    CGFloat * __nullable ascent,

    CGFloat * __nullable descent,

    CGFloat * __nullable leading ) CT_AVAILABLE(10_5, 3_2);

关于爱程序网 - 联系我们 - 广告服务 - 友情链接 - 网站地图 - 版权声明 - 人才招聘 - 帮助