计算label文字的宽高方法

计算label的宽度

CGSize size=[_itemNamelabel.text sizeWithAttributes:@{NSFontAttributeName : [UIFont boldSystemFontOfSize:17]}]; 
size.width

计算label的高度

CGSize size = [self.personalRecommendLabel sizeThatFits:CGSizeMake(width, MAXFLOAT)];
size.height

© 2017. All rights reserved.

Powered by Hydejack v7.5.0