gpt4 book ai didi

ios - adjustsFontForContentSizeCategory 不适用于 UITextView 和 UITextField

转载 作者:可可西里 更新时间:2023-11-01 06:13:04 32 4
gpt4 key购买 nike

我正在从 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/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com