[IOS] label adaptive height wrap

_wifi_analyzer_label.numberOfLines = 0;
_wifi_analyzer_label.lineBreakMode = NSLineBreakByWordWrapping;
CGSize size = [_wifi_analyzer_label sizeThatFits:CGSizeMake(_wifi_analyzer_label.frame.size.height, MAXFLOAT)];
CGRect frame = _wifi_analyzer_label.frame;
frame.size.height = size.height;
[_wifi_analyzer_label setFrame:frame];

 

The above is the code implementation. If you don't use the code, you only need to compress the label height in the storyboard and it will automatically branch;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326228450&siteId=291194637
Recommended