The main is today to see the forum someone asked this question, help solve, by the way mark.
Very simple, the code is very clear. directly on the code.
UILabel *label = [[UILabel alloc] Initwithframe:cgrectmake (10, 100, 300, 50)]; Label.text = @ "This afternoon the city cloudy to overcast with showers or thunderstorms, this night to tomorrow cloudy with showers, rain can reach heavy rain." 5-6-level gust of Wind in the northeast wind 7, gradually enhanced to 6-7-level gust 8 level. Today's high temperature: Around 26, tomorrow morning lowest temperature: 22 or so. This morning, the lowest temperature: 21. Today's UV grade: 2 levels, low intensity of irradiation, appropriate protection. Tomorrow Car Wash Index: Class 4, the weather is rainy, it is not appropriate to wash the car. "; Clear background color Label.backgroundcolor = [Uicolor Clearcolor]; Set the font color to white label.textcolor = [Uicolor Whitecolor]; Set the label's background color to black label.backgroundcolor = [Uicolor blackcolor]; Text centered display label.textalignment = Uitextalignmentcenter; Auto fold line Setting Label.linebreakmode = Uilinebreakmodewordwrap; Label.numberoflines = 0; Adaptive height CGRect txtframe = label.frame; Label.frame = CGRectMake (ten, +, TxtFrame.size.height =[label.text boundingrectwithsize: Cgsizemake (TxtFrame.size.width, Cgfloat_max) Options:nsstringdrawinguseslinefragmentorigin | NsstringdrawingusesfOntleading attributes:[nsdictionary Dictionarywith Objectsandkeys:label.font,nsfontattributename, nil] context:nil].size.height); Label.frame = CGRectMake (ten, +, txtFrame.size.height); [Self.view Addsubview:label];
:
iOS Development-UILabel Auto wrap and Height adaptive