对于行数有限的 UILabel,如何确定要在 [NSString sizeWithFont:constrainedToSize:...] 中使用的 constrainedToSize.height?
下面的约束高度是无限的(MAXFLOAT),但是当限制为 X 行时,标签的最大高度是什么?
UILabel * label = [[UILabel alloc] init];
label.numberOfLines = 2;
label.text = @"Some really long text";
// what to use instead of MAXFLOAT?
CGSize constrainSize = CGSizeMake(285, MAXFLOAT);
CGSize size = [label.text
sizeWithFont: [UIFont boldSystemFontOfSize:17.0]
constrainedToSize:constrainSize
lineBreakMode:NSLineBreakByWordWrapping
];
非常感谢!