boundingRectWithSize返回的size是不正确的

NSMutableParagraphStyle *paragraphStyle = [[NSMutableParagraphStyle alloc]init];

paragraphStyle.lineBreakMode = NSLineBreakByWordWrapping;

上边两句代码一定要加,否则返回的size是不正确的

NSDictionary *attr = @{NSFontAttributeName:packageLabel.font, NSParagraphStyleAttributeName:paragraphStyle.copy};

CGSize packageLabelSize = [packageLabel.text boundingRectWithSize:CGSizeMake(MAXFLOAT, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:attr context:nil].size;

你可能感兴趣的:(boundingRectWithSize返回的size是不正确的)