Pagine

Sunday, 3 November 2013

ICTextView - UITextView with search highlighting

I just took a quick break from my studies to finish this small, fun project I've been working on for some days. I'm open sourcing it because I'm not aware of any other open-source implementation that also supports iOS 4-5.

ICTextView is a custom UITextView subclass that supports string or regex search and match highlighting. It's decently optimized, very easy to use, highly customizable, and it supports highlighting additional search results while the user scrolls.

It also contains a number of iOS 7 improvements and bugfixes over the original UITextView. As an example, the characterRangeAtPoint: method works fine with it, and I introduced a custom implementation of the scrollRangeToVisible: method that accounts for content insets in iOS 7. After reading how many people are having trouble with the countless iOS 7 UITextView bugs, I felt pretty much obliged to share this.

Enough talk. You can find the code and a nicely formatted readme file on GitHub.

ICTextView on GitHub

UPDATE: ICTextView is now available via Cocoapods. Just add "pod ICTextView" to your Podfile and run "pod install". Feel free to report any issue via email, or contribute via GitHub pull requests.