测试一,只改变numberOfLines属性,label的高度不会自适应(会有text中的一部分内容称为......)
NSString *str = @"jgreijgirjeirgjierjgiu4t9eumctuv5 vtmnvghvmc5v5tgh58tc857y";
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(50, 50, 100, 100)];
label.font = [UIFont systemFontOfSize:15];
label.backgroundColor = [UIColor cyanColor];
label.numberOfLines = 0;
label.text = str;
NSLog(@"label1.frame = %@",NSStringFromCGRect(label.frame));
[self.view addSubview:label];