如何计算 UILabel 的字体大小?
我有一个 UILabel
,尺寸为 984x728 px,带有可变文本。如何计算适合 UILabel
的最大字体大小?
I have a UILabel
measuring 984x728 px with variable text. How can I calculate the maximum font size to fit the UILabel
?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
创建一个比您想要的更大的字体(48 磅可能不错)。然后使用这个:
maxFontSize
将保留小于 48 且大于 0 的最大尺寸,以适合maxWidth
。Create a font larger than you would ever want (48 points is probably good). Then use this:
maxFontSize
will hold the largest size less than 48 and greater than 0 that will fit withinmaxWidth
.