I have a goal to implement local search inside Core Data entities. Technical part of finding occurrences is pretty clear. But I'm not sure how to display it correctly. Case: we have string in our entity
Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor
and user want to find entries with word adipiscing
. We have UILabel
with width i.e. 320dp and numberOfLines = 1
. If we will display whole string without correct trimming it would be
Lorem ipsum dolor sit amet, consec...
which just useless for user. I want label to look like
...consectetur adipiscing elit, se...
So in other words I want search occurrence to be "focused" somewhere about middle of UILabel
. How can I trim the string where occurrence has happened depending on label font and width?