Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在将 NSAttributedString 与 Core Text Framework 一起使用时,如何在视图的点击位置下方找到文本的属性(它是 NSAttributedString,其中每个句子都有其唯一的属性)?
直接使用 Core Text,而不是文本视图?我假设你有一个CTFrameRef. CTFrameGetLines()您可以使用and获取线条和线条原点CTFrameGetLineOrigins()。根据其原点找到正确的行,然后用于CTLineGetStringIndexForPosition()获取字符串索引。
CTFrameRef
CTFrameGetLines()
CTFrameGetLineOrigins()
CTLineGetStringIndexForPosition()