swiftswiftuifontsuifont

Using Font in UITextView in Swift


I am currently working with the UITextView and now I wanted to set the font there. As far as I can see, I can only apply the UIFont and not the Font class itself. I found several guides to convert a UIFont to Font, but none for Font to UIFont. Is there a way to do this or is there an equivalent UI class in SwiftUI which has the same functionalities as UITextView and takes a Font instead of UIFont? Thanks in advance :-)


Solution

  • You cannot transform a Font into a UIFont as there is no UIFont init that accepts a Font as a parameter. However, depending on what you want to achieve, you can use the SwiftUI view TextEditor that share some characteristics with UITextView.

    If it doesn't fit your needs, could you share more details about what you are trying to achieve?