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

0
Shares
Displaying Rich Text in iPhone App Development Has Become Easier With Textview
Rate this post

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.

sampletext2

Set your project name and other details.

sampletext3

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

sampletext4

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

sampletext5

sampletext6

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

sampletext7

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.

sampletext8

We can also do this from coding.

Set outlet and delegate of UITextView in ViewController.

class ViewController: UIViewController, UITextViewDelegate

sampletext9

@IBOutlet weak var txtDescription: UITextView!

To open keyboard for edit text in Text View:

txtDescription.becomeFirstResponder()

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
textView.resignFirstResponder()
}

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.

simulator-screen-shot-jan-10-2017-4-41-55-pm

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.

This page was last edited on July 16th, 2018, at 8:39.
 
0
Shares
 

Have an iOS App Idea in Mind? Let's Discuss!

Get your free consultation now