UILabel *tilelabel = [[UILabel alloc] init];
Tilelabel.numberoflines = 0;
Tilelabel.backgroundcolor = [Uicolor Clearcolor];
Tilelabel.text = @"Adjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud HeadAdjust line spacingCloud Head";
Tilelabel.font = [Uifont systemfontofsize:11.0f];
Tilelabel.textcolor = [Tools colorwithhex:0x787878];
nsmutableattributedstring *attributedstring = [[Nsmutableattributedstring alloc] initWithString:tileLabel.text];
Nsmutableparagraphstyle *paragraphstyle = [[Nsmutableparagraphstyle alloc] init];
[Paragraphstyle setlinespacing:18];// adjust line spacing
[Attributedstring addattribute:nsparagraphstyleattributename Value:paragraphstyle range:NSMakeRange (0, [ Tilelabel.text length]);
Tilelabel.attributedtext = attributedstring;
Nsdictionary *attributes = @{nsfontattributename:tilelabel.font, NSParagraphStyleAttributeName:paragraphStyle.copy };
CGFloat height = [Tilelabel.text boundingrectwithsize:cgsizemake (self.view.width-32, Cgfloat_max) options: Nsstringdrawinguseslinefragmentorigin | Nsstringdrawingusesfontleading attributes:attributes context:nil].size.height;
CGFloat height =[self changeStationWidth:tileLabel.text anwidthtxtt:self.view.width-32 anfont:11];
Tilelabel.frame = CGRectMake (0, self.view.width-32, height);
[Self.view Addsubview:tilelabel];
This article is from the "11204872" blog, please be sure to keep this source http://11214872.blog.51cto.com/11204872/1754484
IOS UILabel Setting Line height