UILabel填满一行后自动换行,三句代码搞定

1. OC

_label.lineBreakMode = NSLineBreakByWordWrapping;  
_label.numberOfLines = 0;  
_label.preferredMaxLayoutWidth = ScreenWidth;

2. Swift

_label.lineBreakMode = NSLineBreakMode.byWordWrapping;
_label.numberOfLines = 0;

你可能感兴趣的:(iOS-技术篇)