草庐IT

ios - adjustsFontForContentSizeCategory 不适用于 UITextView 和 UITextField

coder 2023-09-30 原文

我正在从 preferredContentSizeChanged 切换到对我的 UILabelUITextView 使用 adjustsFontForContentSizeCategory >UITextField 类。它适用于 UILabel,但不适用于 UITextViewUITextField。仅当我在 preferredContentSizeChanged 中调用 setNeedsDisplay 时它才有效。

我错过了什么?

最佳答案

您还需要将 UITextfield 使用的字体设置为可缩放:

    textField.adjustsFontForContentSizeCategory = true
    textField.font = .preferredFont(forTextStyle: .body)

关于ios - adjustsFontForContentSizeCategory 不适用于 UITextView 和 UITextField,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46820818/

有关ios - adjustsFontForContentSizeCategory 不适用于 UITextView 和 UITextField的更多相关文章

随机推荐