Andreas Thaler
Andreas Thaler

Reputation: 11

Increasing text size of textView leads to smaller text | Swift iOS

I tried to build a textView with two buttons to in/decrease the size of the text. I used:

textView.font = UIFont(name: "System", size: 50)

But no matter which number I set for the size, the text always becomes the same size (around 11) when calling the method.

Why is that? Could you help me with that?

Upvotes: 1

Views: 734

Answers (1)

user6513320
user6513320

Reputation:

If you would like to do something you said, you can make your own category like this:

extension UITextView {
    func increaseFontSize () {
        self.font =  UIFont(name: self.font!.fontName, size: self.font!.pointSize+4)!
    }
}

To use it just import it like this:

textview.increaseFontSize()

This will increase your text by 4.

Upvotes: 2

Related Questions