Search for NSAttributedString attribute below view tap position

How can I find a text attribute (this is an NSAttributedString, where each sentence has a unique attribute) under the view tap position when using NSAttributedString with the Core Text Framework?

+3
source share
1 answer

Using body text directly, not text representation? I guess you have one CTFrameRef. You can get strings and source strings using CTFrameGetLines()and CTFrameGetLineOrigins(). Find the correct line based on its beginning, and then use CTLineGetStringIndexForPosition()to get the index of the line.

+3
source

All Articles