gpt4 book ai didi

ios - 如何根据 resize 调整 UITextView 的宽度?

转载 作者:塔克拉玛干 更新时间:2023-11-02 21:42:50 28 4
gpt4 key购买 nike

我想问一下如何调整 UITextView 的大小以适应屏幕上显示的文本。

例如

enter image description here

调整 UITextView

enter image description here

谁能帮助我或给我一些建议。谢谢

提示:

我试过了sizeWithFont:constrainedToSize: ,无效

最佳答案

如果您需要知道 NSString 在单行上呈现时所采用的 CGSize,请使用 CGSize sz = [textView.text sizeWithFont: _textView.font] 然后根据此大小值调整框架。

如果您需要知道在多行呈现时文本所采用的大小,并在文本达到给定宽度时将其换行,请使用sizeWithFont:constrainedToSize:lineBreakMode: 相反,等等

关于ios - 如何根据 resize 调整 UITextView 的宽度?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16852578/

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