NSString *namestring = self.dataarray[indexpath.row][@ "user"];
Nsdictionary *[email Protected]{nsfontattributename:llshowmessagenamefont};
Self-adapting width
Float rightnamewidth=[namestring Sizewithfont:[uifont systemfontofsize:15] Constrainedtosize:cgsizemake (1000, 20)]. Width
Self-adapting height
Cgsize Namelabelmaxsize=cgsizemake (Rightnamewidth, maxfloat);
Cgsize namelabelsize=[namestring boundingrectwithsize:namelabelmaxsize Options: Nsstringdrawinguseslinefragmentorigin attributes:namelabelattr context:nil].size;
CGFloat namelabelx = Cgrectgetmaxx (cell.iconView.frame) + Llshowmessagecellborder*kwidthscale;
CGFloat namelabely = CELL.ICONVIEW.ORIGIN.Y;
Cell.nameLabel.frame = (cgrect) {{namelabelx, namelabely}, namelabelsize};
Cell.nameLabel.text = namestring;
If the text does not show all, you need to add the code, you can
[Cell.namelabel SizeToFit];
Lable self-adapting width and height