0
回答
iphone中得到字符串所占空间的大小
利用AWS快速构建适用于生产的无服务器应用程序,免费试用12个月>>>   

NSString *string1 = @"Hi to all!I've this question for you, and i hope you can help me";
CGRect textSize = CGRectMake(0.0, 0.0, 320.0, FLT_MAX);
UIFont *font = [UIFont fontWithName:@"Helvetica-Bold" size:20.0];
UILabel *label = [[UILabel alloc] init];
label.lineBreakMode = UILineBreakModeWordWrap;
// Zero means infinite in this case
label.numberOfLines = 0;
label.font = font;
label.text = string1;
label.frame = [label textRectForBounds:textSize limitedToNumberOfLines:0];
NSLog(@"Frame at width %f height %f", label.frame.size.width, label.frame.size.height);
 


原文链接:http://blog.csdn.net/favormm/article/details/6078386
<无标签>
举报
长平狐
发帖于5年前 0回/66阅
顶部