AdjustsFontSizeToFitWidth 与 SizeToFit [英] AdjustsFontSizeToFitWidth vs. SizeToFit

查看:41
本文介绍了AdjustsFontSizeToFitWidth 与 SizeToFit的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用 SizeToFit 因为我不必指定 Frame 属性来具有 UIButton/<的自适应大小代码>UILabel.就我而言,它是工具栏上的一个按钮.现在我做了以下观察:

I'm using SizeToFit because I don't have to specify the Frame property to have an adaptive size of the UIButton/UILabel. In my case it's a button on a toolbar. Now I made the following observation:

如果我将 AdjustsFontSizeToFitWidthSizeToFit 一起使用,则字体大小不再适用.所以我可以

If I use AdjustsFontSizeToFitWidth together with SizeToFit than the font size isn't adapted anymore. So I can

  1. 指定一个 Frame 并使用 AdjustsFontSizeToFitWidth
  2. 使用 SizeToFit 但不再有可调整的字体大小
  1. Specify a Frame and use AdjustsFontSizeToFitWidth
  2. Use SizeToFit but don't have the adjustable font size anymore

你也有这个问题吗?你如何规避这个问题?如何让内在内容大小驱动帧大小?还是我必须设置 Frame 属性?Autolayout 的优点是不再定义边框大小......

Do you also have this problem? How do you circumvent this problem? How to let the intrinsic content size drive the frame size? Or do I have to set the Frame property? The advantage of Autolayout was to not define a frime size any more ...

推荐答案

我想我在推理上犯了一个错误.SizeToFit 定义内容后的大小(内容已经有固定大小).AdjustsFontSizeToFitWidth 需要一个可以改变字体大小的框架.两者一起不起作用.

I think I made an error in reasoning. SizeToFit defines the size after the content (content has already a fixed size). AdjustsFontSizeToFitWidth needs a frame in which it can change the font size. Both together doesn't work.

这篇关于AdjustsFontSizeToFitWidth 与 SizeToFit的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆