Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

adjustsFontForContentSizeCategory not working for UITextView and UITextField

I'm switching away from preferredContentSizeChanged to use adjustsFontForContentSizeCategory for my UILabel, UITextView, and UITextField classes. It works for UILabel, but not for UITextView and UITextField. It only works if I call setNeedsDisplay inside preferredContentSizeChanged.

What am I missing?

like image 480
koen Avatar asked Oct 29 '22 00:10

koen


1 Answers

You also need to set the font used by the UITextfield to be scalable:

    textField.adjustsFontForContentSizeCategory = true
    textField.font = .preferredFont(forTextStyle: .body)
like image 136
OliverD Avatar answered Nov 11 '22 09:11

OliverD