Displaying Rich Text in iPhone App Development Has Become Easier With Textview

The way technology is growing in various has completely changed we get things done these days. In fact, the iPhone app development market is one of the biggest market where people make buck load of cash. And the features that iPhone app development offer are fascinating, and they continue to grow more powerful and more user-friendly with fresh capabilities. Moreover, the iOS 7 has also brought most significant text rendering with Textview to display rich text in iOS mobile apps.

Today, in our iOS app tutorial, we’ll be developing a simple app to demonstrate the Text view implementation process in an iOS app.

Let’s Get Started

Go to your XCode and create a new project.

Select your Application type as Single View Application and click on next.


Set your project name and other details.


Once you create a new project successfully, go to Main.Storyboard and select ViewController.


Now drag and drop UITextView from “Show the object library” section.



Set auto layout for TextView so it will compatible for all the screens of iPhone devices.


Now select see the attribute inspector which have properties for textview. we can change behavior of textview from here like Type, Text, Text Color, Font type, Alignment, Editable, some kind of detection it text contain Web link, phone number, addresses etc and many more.


We can also do this from coding.

Set outlet and delegate of UITextView in ViewController.

class ViewController: UIViewController, UITextViewDelegate


@IBOutlet weak var txtDescription: UITextView!

To open keyboard for edit text in Text View:


To change return key type use:

txtDescription.returnKeyType = .Done

To give padding to textview:

txtDescription.textContainerInset = UIEdgeInsetsMake(10,15,10,15); // top, left, bottom, right

Implement the textView Delegates

func textView(textView: UITextView, shouldChangeTextInRange range: NSRange, replacementText text: String) -> Bool {

if text == "\n" {
//For dismiss keyboard

return true

func textViewDidBeginEditing(textView: UITextView) {
print("Begin edit in text view")

func textViewDidEndEditing(textView: UITextView) {
print("End editing in text view")

And Done!

Let’s check out the output.


Now that you know the implementation process, you can easily implement the text view to display rich text in your mobile app. Though, there are few other tweaks you can do with text view to present in a richer form, and if you’d like to implement them as well, you can either consult with an expert or hire iPhone app developer to implement in your iPhone app development project.

Grab a free copy of UITextKit Demo Example from Github.

Author Bio
Hitesh Trivedi
Hitesh Trivedi
Designation: iOS Team Lead

Hitesh Trivedi is an iOS Team Lead at Space-O Technologies. He has over 10 years of experience in iOS app development. He has guided to develop over 100 iPhone apps with unique features and functionalities. He has special expertise in Swift and Objective-C.