Align text in UITextView Vertically

Hey All,

I have several UITextViews with a set height. The UITextView get a specific background color so it is important the text within this UITextview gets centered in the middle (vertically) For buttons i can just do:

t.contentHorizontalAlignment = UIControl.ContentHorizontalAlignment.left

When applying this on a UITextView i get this error:

Value of type 'UITextView' has no member 'contentHorizontalAlignment'

How can i achieve the same result for a UITextView?

let categorieDropdown: UITextView = {
    
    let t = UITextView()
    
    t.font = UIFont.boldSystemFont(ofSize: 16.0)
    t.backgroundColor = orangeBanner
    t.textColor = UIColor.white
  
    return t
    
}()

Align text in UITextView Vertically

This question is very UIKit specific, so you might have more luck asking it somewhere dedicated to UIKit, like the App Frameworks > Cocoa Touch topic area on DevForums.

Share and Enjoy

Quinn “The Eskimo!” @ DTS @ Apple