iPhone 字符间距
Is there a way to add character spacing in UILabel?
I found some examples like:
How to change an UILabel/UIFont's letter spacing?
But it's hard to believe that there isn't a easier way.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
除了自定义 Quartz 绘图之外,没有其他方法可以实现您想要的目标,UILabel 不够灵活。然而,其他人已经接受了挑战,例如 OHAttributedLabel 允许您设置 NSAttributedString 作为标签的文本。尝试NSKernAttributeName,它会修改字偶距,但我从未在 iOS 上尝试过,只在 OS X 上尝试过。
There is no other to achieve what you want than doing custom Quartz drawing, UILabel is not flexible enough. However, other people have taken on the challenge, there is for example OHAttributedLabel which allows you to set an NSAttributedString as the label's text. Try the NSKernAttributeName, it modifies kerning but I've never tried this on iOS, only OS X.
在IB中,您可以点击调整以适应和(以字体大小),并在布局中将行数设置为“0”,以达到接近您的要求。(或您也可以通过代码来完成)。
In IB you can click on Adjust to fit and (In font size), and set lines to '0' in in layout, to achieve near to your requirement.(or you can do it by code too).