使用父视图缩放 UILabel 文本

发布于 2024-09-15 12:20:21 字数 114 浏览 2 评论 0原文

我有一个 UILabel,它是较大 UIView 的子视图。有没有办法使 UILabel 内的文本与父 UIView 成比例,以便当父级更改大小(变小或变大)时,UILabel 中文本的字体大小将按比例增大和缩小?

I have a UILabel that is a subview of a larger UIView. Is there a way to keep the text inside the UILabel proportional to the parent UIView so that when the parent changes size, either smaller or larger, the font size for the text in the UILabel will grow and shrink proportionally?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

不再让梦枯萎 2024-09-22 12:20:21

我认为没有简单的方法,只能计算父视图变大或变小了多少,并利用该数量使字体变小或变大。例如,如果父视图宽度小 50 像素,则字体小 5 磅。希望有帮助

I think there is no easy way but to calculate how much the parent view went bigger or smaller and taking that quantity making the font smaller or larger. For example if the parent view is smaller by 50 pixels wide then making the font 5 pts smaller. Hope it's helpful

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文