iOS 根据文字的多少计算label宽度
2016-12-01 本文已影响957人
彗星来的那一夜
NSDictionary *attrs = @{NSFontAttributeName : [UIFont boldSystemFontOfSize:17]};
CGSize size=[_itemNamelabel.text sizeWithAttributes:attrs];
[self.itemNamelabel setFrame:CGRectMake(40, 10, size.width, 20)];