CYRTextView

Prior to iOS 7, rich text editing was a beast. Apps that supported rich text in any meaningful fashion were few and far between. iOS 7 changed all that. What was once took herculean effort is now child’s play!

I’ve started working on an iOS 7 optimized version of QED Solver. A big part of this is re-factoring the rich text editor view. I was able to whip up a prototype in about 2 hours thanks to some excellent TextKit resources. Another partial weekend, and CYRTextView was born. Here’s how it looks right now:

CYRTextView

CYRTextView is a UITextView subclass that implements a variety of features that are relevant to a syntax or code text view. There are many subclasses of UITextView out there with the release of TextKit but none that are specifically tailored towards a code/syntax view. CYRTextView aims to change this. Features include:

  • Regular expression based text highlighting with support for multiple text attributes for each expression
  • Line numbers
  • Gesture based navigation

CYRTextView leverages code from NLTextView and a TextKit line number demo from Mark Alldrit.

Long term, I would like to turn CYRTextView into a full fledged code editor component with code folding, markers, annotations, and more. I’ve included a sample project that should help get you started.

Get The Code

You can find CYRTextView here: https://github.com/illyabusigin/CYRTextView

I’d be delighted to see a pull-request with a bug-fix or new feature. If you find an issue please use the issue tracker for the GitHubrepository.

I hope you are able to use or learn something from CYRTextView!