Objective C - UILabel多线垂直间隙高度 [英] Objective C - UILabel multiline vertical gap height

查看:111
本文介绍了Objective C - UILabel多线垂直间隙高度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个多行UILabel,最多可以使用3行。
,即message.numberOfLines = 3;

I have a multiline UILabel that can take a maximum of 3 lines. i.e message.numberOfLines = 3;

一切正常,但我如何设置线条之间的垂直间隙?
例如在第1行和第2行之间等?

Everything works fine, but how can I set the vertical gap between the lines? e.g between line 1 and line 2 etc?

请点亮,

Tee

Please enlight,
Tee

推荐答案

我一直无法找到调整线条间距的方法。 UILabel的字体属性有许多只读属性,因此无济于事。

I haven't been able to find a way to adjust the spacing between lines. The font property of UILabel has a number of read-only properties, so that won't help.

如果我想更改行间距,我会使用自己的文字。我使用NSString的-drawAtPoint和-drawInRect,并使用一个或多个-sizeWithFont方法来确定文本的分割时间,以便分割文本并在每行中绘制正确数量的单词或字符。

I've resorted to draw my own text if I want to change the line spacing. I use NSString's -drawAtPoint and -drawInRect and use one or more of the -sizeWithFont methods to figure out how long the text will be in order to split the text and draw the right number of words or characters per line.

这篇关于Objective C - UILabel多线垂直间隙高度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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