我的UILabel有问题。我想显示多行注释。但他们是单线。这是我的代码:
CGRect currentFrame = comment.frame;
CGSize max = CGSizeMake(comment.frame.size.width,20000.0f);
CGSize expected = [comment.text sizeWithFont:[UIFont systemFontOfSize:10.0] constrainedToSize:max lineBreakMode:UILineBreakModeWordWrap];
currentFrame.size.height = expected.height;
comment.frame = currentFrame;
comment.numberOfLines = 0;
[comment sizeToFit];
但结果并不好。我哪里错了?
答案 0 :(得分:0)
您的代码没问题,但您应该在代码中添加此行以获得多行
comment.lineBreakMode = UILineBreakModeWordWrap;