我有一个 NSString,我想知道它的高度以创建一个合适的 UILabel。
这样做
NSString *string = @"this is an example";
CGSize size = [string sizeWithFont:[UIFont systemFontOfSize:10.0f]
forWidth:353.0
lineBreakMode:UILineBreakModeWordWrap];
float height = size.height;
高度现在是 13.0。如果我使用这个字符串
NSString *string = @"this is an example this is an example this is an example
this is an example this is an example this is an example
this is an example this is an example this is an example
this is an example this is an example this is an example
this is an example this is an example this is an example
this is an example ";
高度始终为 13.0(宽度为 353,这是不可能的)......我做错了什么?
添加:
size.width;
工作正常......所以就像 lineBreakMode 不正确......但它是,不是吗?