ios UILabel字型的行間距

2021-06-26 21:10:40 字數 854 閱讀 4831

#define linespace 20

uilabel *label = [[uilabel alloc] initwithframe:cgrectmake(0, 100, 320, 200)];

[label setbackgroundcolor:[uicolor blackcolor]];

[label settextcolor:[uicolor whitecolor]];

[label setnumberoflines:0];

nsstring *labeltext = @"可以自己按照寬高,字型大小,來計算有多少行。。然後。。。每行畫乙個uilabel。。高度自己可以控制把這個寫乙個自定義的類。 ";

nsmutableattributedstring *attributedstring = [[nsmutableattributedstring alloc] initwithstring:labeltext];

nsmutableparagraphstyle *paragraphstyle = [[nsmutableparagraphstyle alloc] init];

[paragraphstyle setlinespacing:linespace];//調整行間距

[attributedstring addattribute:nsparagraphstyleattributename value:paragraphstyle range:nsmakerange(0, [labeltext length])];

label.attributedtext = attributedstring;

[self.view addsubview:label];

[label sizetofit]

iOS UILabel自定義行間距時獲取高度

參考 本文介紹一下自定義行間距的uilabel的高度如何獲取,需要借助一下開源的uilabel控制項 tttattributedlabel import tttattributedlabel.h 直接上 nsstring str uilabel自定義行間距時獲取高度,uilabel自定義行間距時獲取...

CSS定義字型間距 字型行與行間距

css定義字型行間距 line height xxpx css定義字型間距 下面我們講述一下css的文字屬性,還是先來看一下文字屬性的詳細列表 屬性 屬性含義 屬性值 word spacing 定義了各個單詞之間的間距 normal必須以長度為單位 letter spacing 定義了每個字母之間的...

CSS定義字型間距 字型行與行間距

1 2letter spacing 畫素 字母或中文字的左右間距 34 word spacing 畫素 兩個單詞之間的左右間距 56 line height 畫素 兩行之間的間距 78 text decoration 字型的裝飾 如刪除線等 910 vertical align 垂直上的位置 111...