UILabel:调整边距以匹配 UITextView
我有一个 UILabel,如果我调整文本的大小,我可以使它看起来像 UITextView,但是左边距不同,在 UIlabel 上,文本正好靠在 UITextView 有轻微边距的左边框上。我如何调整 UILabel 以便当这些控件放置在另一个控件之上时,它们看起来一致?
I have a UILabel and if i adjust the size of the text i can make it look loke a UITextView however the left margin is different, on the UIlabel the text is right up against the left border where the UITextView has a slight margin. How do i adjust the UILabel so that when these controls are placed above one another, they look consistent?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
只需更改标签的框架:
当然,将 MARGIN 替换为您想要的边距。
或者您可以子类
UILabel
并重写textRectForBounds:limitedToNumberOfLines:
如下所示:希望这会有所帮助!
Simply change the label's frame:
Of course replace MARGIN with whatever you want your margin to be.
Or you could subclass
UILabel
and overridetextRectForBounds:limitedToNumberOfLines:
like so:Hope this helps!