1 | - (CGSize)getsize:(NSString *)str wid:(CGFloat)th font:(CGFloat)size |
2 | { |
3 | CGSize constraint = CGSizeMake(th, 20000.0f); |
4 | CGSize size_ = [str sizeWithFont:[UIFont systemFontOfSize:size] constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap]; |
5 | return size_; |
6 | } |
根据计算出来的高度,和指定的宽度,设置label的size即可。