ios - find out height of a UILabel which is size to fit -



ios - find out height of a UILabel which is size to fit -

i trying find out height of uilabel when height of uilabel changes dynamically when sizetofit enabled. way figure out height of uilabel? of course of study value frame.size.height wrong when enable sizetofit.

thanks.

try may help you..

-(cgsize)lblsize:(nsstring *)content lblfont:(uifont *)contectlblfont width:(int)width { cgsize maximumlabelsize; maximumlabelsize = cgsizemake(width,9999); nsattributedstring *attributedtext = [[nsattributedstring alloc] initwithstring:content attributes:@ { nsfontattributename:contectlblfont }]; cgrect rect = [attributedtext boundingrectwithsize:(cgsize){maximumlabelsize.width, cgfloat_max} options:nsstringdrawinguseslinefragmentorigin context:nil]; cgsize size = rect.size; homecoming size; }

and utilize within table view delegate

cgsize expectedlabelsize=[self lblsize:[nsstring stringwithformat:@"%@",[[loadmorearray objectatindex:indexpath.row]valueforkey:@"text"]] lblfont:cell.self.lbldetail.font width:310]; cell.self.lbldetail.frame=cgrectmake(5,cell.imgprofile.frame.size.height+cell.imgprofile.frame.origin.y+2, 300,expectedlabelsize.height+10);

ios uilabel

Comments

Popular posts from this blog

php - Android app custom user registration and login with cookie using facebook sdk -

django - Access session in user model .save() -

php - .htaccess Multiple Rewrite Rules / Prioritizing -