UILabel *label = [[UILabel alloc]initwithframe:cgrectmake (KSCREENWIDTH-20, 40)]; Label.numberoflines = 0; Label.font = [Uifont systemfontofsize:20]; Label.text = @ "Waiter refers to a fixed place to provide a certain range of services, a male waiter, also a waitress, now usually refers to hotels, restaurants, KTV, D Hall and other places of entertainment, to provide guests with the necessary service personnel. The basic duties of the waiter are to greet and greet the customers, to provide all kinds of corresponding services, to answer the customer's inquiries, to solve the difficulties for the customers, to treat the customers ' various moods with the best emotion and attitude, to deal with the customers ' complaints in time, and to give the guest satisfactory reply. "; [Self.view Addsubview:label]; nsmutableattributedstring *attributedstring = [[nsmutableattributedstring alloc]initwithstring:label.text];; Nsmutableparagraphstyle *paragraphstyle = [[Nsmutableparagraphstyle alloc]init]; [Paragraphstyle Setlinespacing:5]; [Attributedstring addattribute:nsparagraphstyleattributename Value:paragraphstyle range:NSMakeRange (0, Label.text.length)]; Label.attributedtext = attributedstring; Adjust height cgsize size = cgsizemake (label.bounds.size.width, 500000); Cgsize labelsize = [Label sizethatfits:size]; CGRect frame = label.frame; Frame.size = labelsize; Label.frame = frame; Label.backgroundcolor = [Uicolor Redcolor];
Set the line spacing for labels