I have an NSString, and I want to know its height to create an appropriate UILabel.
Doing this
NSString *string = @"this is an example";
CGSize size = [string sizeWithFont:[UIFont systemFontOfSize:10.0f]
forWidth:353.0
lineBreakMode:UILineBreakModeWordWrap];
float height = size.height;
height is now 13.0.
If I use this string
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 ";
height is always 13.0 (and with 353 as width, that's impossible)... what am I doing wrong?
ADD:
size.width;
works fine... so it's like if the lineBreakMode is not correct... but it is, isn't it?
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…