Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Finding NSAttributedString's attribute below the tap position of the view

How can i find attribute of the text (it's NSAttributedString where each sentence have it's unique atribute) below the tap position of the view, while using NSAttributedString with Core Text Framework?

like image 825
izaslavs Avatar asked Jan 20 '26 23:01

izaslavs


1 Answers

Using Core Text directly, not a text view? I assume you have a CTFrameRef. You can get the lines and the line origins using CTFrameGetLines() and CTFrameGetLineOrigins(). Find the right line based on its origin and then use CTLineGetStringIndexForPosition() to get the string index.

like image 159
Ken Thomases Avatar answered Jan 22 '26 13:01

Ken Thomases



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!