ios - A:Set text line-space by my method, when the characters length is 14-15 , it will show only one line -
my label maintitle
set line space:
[util setlabellinespace:22 forlabel:((noticeannouncementcell*)cell).maintitle andstr:((informationmodel *)self.datasource[indexpath.row]).title];
the util method:
+ (void)setlabellinespace:(float)spacing forlabel:(uilabel *)label andstr:(nsstring *)originstr{ //label.numberoflines = 0; if (originstr == nil) { originstr = @""; } nsstring* string = originstr; nsmutableparagraphstyle *style = [[nsmutableparagraphstyle alloc] init]; style.minimumlineheight = spacing; style.maximumlineheight = spacing; nsdictionary *attributtes = @{nsparagraphstyleattributename : style}; label.attributedtext = [[nsattributedstring alloc] initwithstring:string attributes:attributtes]; [label sizetofit]; }
the string
should 黑龙江吉林等地有暴雨 局部大暴雨
, use util method set line space, shows 黑龙江吉林等地有暴雨 局部大
1 line, should 黑龙江吉林等地有暴雨 局部大暴雨
2 line. if string
add character make length longer , 2 line,and no issue first cell.
Comments
Post a Comment