How to change the font and color on the UITextView in iOS?

iOSApps/ApplicationsMobile Development

Changing font and color on UITextView is simple, you just need to update the .textColor and .font property on UITextView object, Here we will be seeing how to do so.

So let’s get started,

Open Main.storyboard and add UITextView as shown below,

Create @IBOutlet of UITextView and name it, textView.
   @IBOutlet var textView: UITextView!

In your viewDidLoad method of ViewController.swift write below lines,

textView.textColor = UIColor.cyan
textView.font = UIFont(name: "Callout", size: 20)

Final Code should look like,

import UIKit
class ViewController: UIViewController {
   @IBOutlet var textView: UITextView!
   override func viewDidLoad() {
      super.viewDidLoad()
      textView.textColor = UIColor.cyan
      textView.font = UIFont(name: "Callout", size: 20)

Run the app,

raja
Published on 30-Aug-2019 14:20:31
Advertisements