UITextView is a good control for displaying text in iOS. It is a scrolling view that presents formatted text on demand. It performs all the work of laying out the text and responding to changes in text, so you can focus on the content of the text. In the iPhone software keyboard, a UITextView provides the keyboard with its text. In iOS 4, UITextView makes it easy to automatically resize itself when the keyboard is displayed. In addition, in iOS 4, the UITextView class supports two new properties, textContainer and textContainerInset, that allow you to get and set the frame of the text container, which encloses the text but not the text container itself.

The UITextView is an iOS text view that is used for displaying pieces of text and associated images. UITextView is a subclass of UIView and a member of UITextInput protocol, which makes it very versatile. As the name implies, UITextView focuses on text content rather than presenting the entire body of an HTML document.

A look at the growth

UITextView in Swift. Supports car expansion, placeholders and length restriction.


iOS 8.0 or higher



GrowingTextView is available through CocoaPods. To install
, simply add the following line to your podfile:

Swift 5.0

pod GrowingTextView, ‘0.7.2

Swift 4.2

pod GrowingTextView, 0.6.1.

Swift 4.1

pod GrowingTextView, ~> 0.5.

Swift 3

pod ‘GrowingTextView’, ‘~> 0.4’.

Swift 2.3 (update stopped since september 2016)

pod GrowingTextView, :git => https://github.com/KennethTsang/GrowingTextView.git, :branch => swift2


GrowingTextView is also available from
Carthage. To install it, add the following line
to your cart file:

Swift 5.0

github KennethTsang/GrowingTextView ~> 0.7

Swift 4.2

github KennethTsang/GrowingTextView ~> 0.6

Swift 4.1

github KennethTsang/GrowingTextView ~> 0.5

Swift 3

github KennethTsang/GrowingTextView ~> 0.4

Swift 2.3 (update stopped since september 2016)

github KennethTsang/GrowingTextView swift2


Copy GrowingTextView.swift to your project.



GrowingTextview is simply a text viewer. Download a sample to see how you can use it as an input toolbar like in other instant messaging applications.

Use of the GrowingTextview software

let textView = GrowingTextView()
textView.delegate = self

Using GrowingTextview in the storyboard

  1. Drag a TextView onto the storyboard and drop it there.
  2. Define the class GrowingTextView.
  3. Define a delegation to the view controller.

Sometimes the view controller does not automatically and correctly configure the insertion of the text view. To avoid this, set the value false for automaticallyAdjustsScrollViewInsets.

override func viewDidLoad() {
automaticallyAdjustsScrollViewInsets = false


Parameter Type Description Standard
maxLength Int Maximum text length. Text that exceeds the limit is truncated. 0 means there is no limit. 0
trimWhiteSpaceWhenEndEditing Boolean Cuts spaces and newline characters when you are done editing in the text area. really
Filling Thong? Text on the support. zero
placeholderColor UIColor The color of the filler text. UIColor(white:0.8, alpha:1.0)
allocated place holder NSAttributedString ? Substitute text assigned. zero
minHeight CGFloat Minimum height of the text window. 0.0
maxHeight CGFloat Maximum height of the text field. 0.0


textView.maxLength = 140
textView.trimWhiteSpaceWhenEndEditing = false
textView.placeholder = Sag something
textView.placeholderColor = UIColor(white : 0.8, alpha : 1.0)
textView.minHeight = 25.0
textView.maxHeight = 70.0
textView.backgroundColor = UIColor.whiteColor()
textView.layer.cornerRadius = 4.0


  1. Take GrowingTextViewDelegate instead of UITextViewDelegate.
  2. Implements the textViewDidChangeHeight function.
  3. Call layoutIfNeeded() in the super view within the animation.

ViewController class: UIViewController, GrowingTextViewDelegate {
func textViewDidChangeHeight(_ textView : GrowingTextView, height : CGFloat) {
UIView.animate(withDuration : 0.2) {


GrowingTextViewDelegate is inherited from UITextViewDelegate. You can use the delegate function as a normal UITextView.

ViewController class: UIViewController, GrowingTextViewDelegate {
func textViewDidChange(_ textView : UITextView) {

func textViewDidEndEditing(_ textView : UITextView) {


For more information on ITUextViewDelegate, visit https://developer.apple.com/reference/uikit/uitextviewdelegate.


Kenneth Zang, [email protected].



This source has been very much helpful in doing our research. Read more about change textview height programmatically swift and let us know what you think.

uitextview mentions swift githubuitextfield placeholder animation swiftuitextview placeholder swiftnextgrowingtextviewcustom uitextfield swift githubread more textview swift github,People also search for,Privacy settings,How Search works,uitextview mentions swift github,uitextfield placeholder animation swift,uitextview placeholder swift,change textview height programmatically swift,nextgrowingtextview,custom uitextfield swift github,read more textview swift github,floating textfield in swift github

You May Also Like

Android library for in-app language changes support in your app

As any user, you may want to view your app in a…

How to choose cross-entropy loss function in Keras?

Inputs: 1) A model. It can be any Keras model. 2) An…

🥇 Send Voice Notes on Telegram  Step by Step Guide ▷ 2020

Telegram is currently regarded worldwide as a very popular instant messaging application.…

🥇 Use Featured Links in FB Live  Step by Step Guide ▷ 2021

Live video is one of the most widely used means of communicating…