younatics / Highlighter

🖍 Highlight whatever you want!
MIT License
933 stars 55 forks source link

POP Implementation #2

Closed IanKeen closed 7 years ago

IanKeen commented 7 years ago

Hey, Interesting lib

I had a quick play at a protocol oriented version if you are interested

https://gist.github.com/IanKeen/537d70bf02fad763c096e6fbb5c1dc69

The biggest pro to this approach is you are able to break out the highlightable elements and use protocol extensions to provide a default highlighting implementation.

The boilerplate for the elements that conform to Highlightable would have been reduced greatly if UITextView didn't use IUOs for its text/attributedText properties :(

The only API change this introduces is the removal of the HighlighterType enum. Instead you just pass in the type of the item you are targeting i.e. UIButton.self for buttons or nil for everything.

Let me know if you'd be interested in a PR

younatics commented 7 years ago

Hello @IanKeen I love it! Could you make pull request for me? Thanks!