在storyboard的attributes inspector中设置:
Lines: 设置为 “0”
Line Breaks:设置为 “Word Wrap”
你应该需要将lable的高度约束也在代码中进行修改:
CGSize sizeThatShouldFitTheContent = [self.nameLable sizeThatFits:self.nameLable.frame.size];
self.nameameLableHeightConstraint.constant = sizeThatShouldFitTheContent.height;
或者可以参考:
textLabel.lineBreakMode = NSLineBreakByWordWrapping;
textLabel.numberOfLines = 0;
(iOS6及以下)
textLabel.lineBreakMode = UILineBreakModeWordWrap;
textLabel.numberOfLines = 0;
转载自:
http://stackoverflow.com/questions/990221/multiple-lines-of-text-in-uilabel