Question

I have a table with search capability. When the user types I display matched names using NSpredicate. I want to highlight the matched letter(s). I am currently using NSAttributedString and finding all the occurrences of the user input using rangeOfString:options:range: in a while loop. I was wondering if there is an efficient way to do this.

Example user searches types e in the following list

Joe

Michel

In results all the e's should be bold

Thanks

Was it helpful?

Solution

You can use TTTRegexAttributedLabel- https://github.com/kwent/TTTRegexAttributedLabel or TTTAttributedLabel - https://github.com/mattt/TTTAttributedLabel.

You can change your UILabel to any of the above labels and highlight your searched word or letter.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top