iOS CoreText CTLineGetStringRange with CTLineRef from CTLineCreateTruncatedLine

匿名 (未验证) 提交于 2019-12-03 09:05:37

问题:

I have the following code in iOS:

CFAttributedStringRef attributedString = ... CTLineRef line = CTLineCreateWithAttributedString(attributedString); CTLineRef truncatedLine = CTLineCreateTruncatedLine(line, 50.0, kCTLineTruncationEnd, NULL);  CFRange lineRange = CTLineGetStringRange(line); CFRange truncatedLineRange = CTLineGetStringRange(truncatedLine); 

My lineRange is the same as truncatedLineRange. Why? The documentation makes no mention of this.

回答1:

According to the coretext-dev mailing list, this is expected behavior:

The truncated string still covers the original string range, it's just that some glyph(s) have subsumed the truncated characters. Besides, it would be impossible to represent a discontiguous string range as a CFRange in the case of middle truncation.



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!