IOS 6 and iOS7 are not the same, so we separate them:
IOS6:
// calculates the actual frame size and turns the label frame to the actual size Cgsize size01 = [ssizewithfont:[uifontsystemfontofsize:15.0f]constrainedtosize:sizelinebreakmode: Nslinebreakbywordwrapping]; [Label Setframe:cgrectmake (ten,size01.width, size01.height)];
IOS7:
UILabel *label = [[UILabel alloc] Initwithframe:cgrectmake (0,0, -, $)]; NSString*str=@"Hair Evil can not grandma ask service on the gnawing found I see can as soon as possible stability fine amount for you holiday"; Label.text=str; Uifont*font=[uifont systemfontofsize: the]; Label.font=font; //Split LineLabel.linebreakmode=nslinebreakbywordwrapping; //set Multiple lines[Label Setnumberoflines:0]; //set the width and height of the maximum sizeCgsize Size=cgsizemake ( -, +); //Get current fontNsdictionary *[email protected]{nsfontattributename: [Uifont systemfontofsize: the]}; Cgsize authsize=[str boundingrectwithsize:size options:nsstringdrawinguseslinefragmentorigin Attributes:dict context:nil].size; Label.frame=cgrectmake ( -, -, Authsize.width, authsize.height); [Self.view Addsubview:label];
IOS Label Wrap IOS6 and IOS7