当我们增加 fontSize 时,标签内的文本如何调整?
在某些应用程序中,我发现我们可以选择增加或减少标签内文本的字体大小。但是当我们调整它时,标签会自动增加其高度以包含它。每次增加或减少字体大小时,如何获取标签的高度?
在某些情况下,例如加载新闻应用程序时,只会有文本。但突然图像出现,文本重新调整自身以包含它。它自己是如何做到的?
有人请帮助我...
In some of the applications, I have seen that we have an option to increase or decrease the fontSize of the text inside the label. But when we adjust it, the label automatically increases its height to contain it. How do we get the height of the label everytime we increase or decrease the fontsize?
And in some cases like news applications when it loads, there will be text only. But suddenly the image comes and the text readjusts itself to contain it. How does it do it by itself?
Someone plz help me...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
签出 NSString UIKit 添加。它有几个方法可以让你询问一个字符串在使用给定字体渲染时有多大。有了这些信息,您应该能够通过一点数学来根据需要进行调整。
此外,在某些情况下,它可能是网络视图。如果是这种情况,HTML/CSS 会自动流动内容以保持整洁。
Checkout NSString UIKit Additions. It has got a couple of these methods that let you ask a string how big it would be when rendered with a given font. With that information, you should be able to adjust things however you need with a little math.
Also, in some cases, it may be a web view. If this is the case, HTML/CSS sort of flows stuff around automatically in order to keep things tidy.