1

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?

  • Do you use `attributedText` property of `textView`? If that's the case: http://stackoverflow.com/questions/37120535/uitextview-attributed-text-not-working-when-using-custom-font/37132592#37132592 – Larme Jun 30 '16 at 10:21
  • Actually no. I am new to Swift, could you help me, how to use it? – Andreas Thaler Jun 30 '16 at 10:24

1 Answers1

2

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.