iOS 根据文字的多少计算label宽度
NSDictionary *attrs = @{NSFontAttributeName : [UIFont boldSystemFontOfSize:17]};
CGSize size=[_itemNamelabel.text sizeWithAttributes:attrs];
[self.itemNamelabel setFrame:CGRectMake(40, 10, size.width, 20)];
iOS 根据文字的多少计算label宽度
NSDictionary *attrs = @{NSFontAttributeName : [UIFont boldSystemFontOfSize:17]};
CGSize size=[_itemNamelabel.text sizeWithAttributes:attrs];
[self.itemNamelabel setFrame:CGRectMake(40, 10, size.width, 20)];
转载于:https://my.oschina.net/huqiji/blog/961856