label根据文字自动适应大小

UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(20, 100, 150, 10)];
[label sizeToFit];

编程技巧