根据帧大小设置UILabel字体大小?(Set UILabel font size according to its frame size?)

编程入门 行业动态 更新时间:2024-10-28 20:25:37
根据帧大小设置UILabel字体大小?(Set UILabel font size according to its frame size?)

我有一个应用程序,允许用户使用缩放手势来缩放标签如何根据新的框架大小更改字体大小,以便字体适合框架矩形?

我目前的步骤只是使用新转换设置标签,并且如果标签太小/太大,文本将显得模糊。 我想确保标签可以根据新的框架矩形清楚地显示文本的最大尺寸。

I have an application that allow user to use the pinch gesture for scaling the label How can I change the font size according to the new frame size so that the font just fit in the frame rectangle?

My current step is only set the label with new transform, and the text will look blur if the label is scaled too small/large. I want to ensure that the label can display the text clearly where the text can have the max size according to the new frame rectangle.

最满意答案

myLabel.adjustsFontSizeToFitWidth = YES;

如果您使用的是InterfaceBuilder,请检查标签的“Autoshrink”。

确保“最小尺寸”不是太大。

myLabel.adjustsFontSizeToFitWidth = YES;

If you're using InterfaceBuilder, check "Autoshrink" for the label.

Make sure that "Minimum Size" is not too large.

更多推荐

本文发布于:2023-07-08 02:41:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1071090.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:字体大小   大小   UILabel   Set   size

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!