Choosing the right view between UILabel and UITextView to display text inside your iOS, iPadOS and macOS Catalyst App

The dilemma of choosing between UILabel and UITextView starts when you want to display text in your Apple iOS, iPadOS or macOS Catalyst App.

I have even gone through this process of choosing UILabel or UITextView to display text on my app.

So I have made a small numbered list to help you out to choose the right option…

Choose UILable to display text:

  1. If the text word count is small in number
  2. If Top Aligning text to the top border is not the requirement
  3. UILable is not tappable or interactive or selectable to the user’s input
  4. if you want to automatically adjust the font size and fit text to the UILabel bounding box layout

Here is Sample Code for UILabel:

self.helpUILabelText.textAlignment = .left
self.helpUILabelText.font = UIFont.systemFont(ofSize: 15, weight: .regular)
self.helpUILabelText.numberOfLines = 0
self.helpUILabelText.text = "Your Text"
self.helpUILabelText.textColor = .black
self.helpUILabelText.lineBreakMode = .byTruncatingTail
self.helpUILabelText.isHidden = false

Choose UITextView to display text:

  1. If the text has a big word count
  2. If you want top text alignment by default
  3. If you want text view to be scrollable / You can mark this feature false also
  4. If you want it interactive with taps from user / You can mark this feature false also
  5. If you want it editable by the user / You can mark this feature false also
  6. If you want it to selectable by user / You can mark this feature false also
  7. If you want line break or paragraph text automatically

Here is Sample Code for UITextView

self.helpUITextView.textAlignment = .left
self.helpUITextView.font = UIFont.systemFont(ofSize: 15, weight: .regular)
self.helpUITextView.text = "Your Text"
self.helpUITextView.textColor = .black
self.helpUITextView.sizeToFit()
self.helpUITextView.backgroundColor = .clear
self.helpUITextView.isHidden = false
self.helpUITextView.isEditable = false
self.helpUITextView.isScrollEnabled = true
self.helpUITextView.isSelectable = false

I hope this information helps you to select the right ‘view’ to display text.

Thanks & Regards
Mandar Apte

Mandar Apte

This website contains a design articles blog by Mandar Apte. He writes and shares his iOS development, graphic, web, & animation film design experience through articles. Mandar is Mumbai based multi-disciplinary designer with expertise in UI, UX, Logo, Symbol, and Brand Identity design. He is an alumnus of Sir J. J. Institute of Applied Art, Mumbai. He currently runs his studio in the heart of the city of Mumbai.

Leave a Reply

Your email address will not be published. Required fields are marked *