简体   繁体   English

根据帧大小设置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;

If you're using InterfaceBuilder, check "Autoshrink" for the label. 如果您使用的是InterfaceBuilder,请选中“Autoshrink”作为标签。

Make sure that "Minimum Size" is not too large. 确保“最小尺寸”不要太大。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM