label 高度 宽度自适应

UILabel *content_lab = [[UILabel alloc] init];
content_lab.textColor = UIColorFromHex(0x333333);
content_lab.font = [UIFont systemFontOfSize:13];

 content_lab.text = self.shuoMing;
CGSize size = CGSizeMake(Screen_width - x - 14, MAXFLOAT);//设置高度宽度的最大限度
CGRect rect = [content_lab.text boundingRectWithSize:size options:NSStringDrawingUsesFontLeading|NSStringDrawingTruncatesLastVisibleLine|NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName : [UIFont systemFontOfSize:13]} context:nil];
content_lab.numberOfLines = 0;
content_lab.frame = CGRectMake(x, 30, Screen_width - x - 14, rect.size.height + 20.0);

你可能感兴趣的:(label 高度 宽度自适应)