/* Adjust line spacing */+ (void) Adjustlinespacingoflabel: (UILabel *) label to: (CGFloat) linespacing{nsstring *textstr = Label.text; if (textstr.length <= 0) {return; } nsmutableattributedstring *attributedstring = [[Nsmutableattributedstring alloc] initwithstring:textstr]; Nsmutableparagraphstyle *paragraphstyle = [[Nsmutableparagraphstyle alloc] init]; [Paragraphstyle setlinespacing:linespacing]; [Paragraphstyle Setlinebreakmode:nslinebreakbytruncatingtail]; [Attributedstring addattribute:nsparagraphstyleattributename Value:paragraphstyle range:NSMakeRange (0, [textStr Length]); Label.attributedtext = attributedstring; [Label SizeToFit];} + (Cgsize) Sizeofmultilinelabel: (NSString *) alabeltextstring font: (Uifont *) Alabelfont constrainedtosize: (CGSize) MaxSize linespacing: (cgfloat) linespacing{if ([[[[Uidevice Currentdevice] systemversion] Floatvalue] < 7.0) { Version < 7.0 return [alabeltextstring Sizewithfont:alabelfont Constrainedtosize:maxsize Linebreakmode:nslinebreakbytruncatingtail]; } else if ([[[[Uidevice Currentdevice] systemversion] floatvalue] >= 7.0) {//version >= 7.0//retur n the calculated size of the Label nsmutableparagraphstyle *paragraphstyle = [[Nsmutableparagraphstyle alloc] init] ; [Paragraphstyle setlinespacing:linespacing]; [Paragraphstyle setlinebreakmode:nslinebreakbywordwrapping]; return [alabeltextstring boundingrectwithsize:maxsize options:nsstringdrawing Useslinefragmentorigin Attributes:@{nsfontattributename:alabelfont, Nsparagraphs Tyleattributename:paragraphstyle} context:nil].size; } return Cgsizezero;}
UILabel Adjust line spacing