Want to offer native, in-app customer service to your users? Get going quickly with Zendesk’s Mobile SDKs. Free with Zendesk.

Some libraries and frameworks provide large, far-reaching sets of tools for us to build our apps. Sometimes though, we just need a single component. Today we'll look at one such component that does one thing and one thing well: text views that adjust their height as a user types into them.

It's called NextGrowingTextView and it's by Hiroshi Kimura.

let textView = NextGrowingTextView(frame: CGRect.zero)

Then, we can use it as the inputAccessoryView of our view controller. This will cause it to be displayed when it becomes first responder. (Be sure to also return true from canBecomeFirstResponder too!)

self.inputAccessoryView = textView

NextGrowingTextView has a couple of properties for min/max number of allowed lines, but the real star is its robust delegates property allowing us to set closures for all sorts of events:

textView.textViewDidChange = { textView in print(textView) }

More info about NextGrowingTextView can be found at git.io/growingtextview