//需要判断是否登录
NSString *str =
@"866.44";
//设置字体UIFont
UIFont *font = [UIFont systemFontOfSize:13];
//这里是设置最大尺寸CGSize
CGSize size = CGSizeMake(320,2000);
//设置label的rectCGRect
CGRect labelRect = [str
boundingRectWithSize:size
options:(NSStringDrawingUsesLineFragmentOrigin|NSStringDrawingUsesFontLeading)
attributes:[NSDictionary
dictionaryWithObject:font
forKey:NSFontAttributeName]
context:nil];
//用刚才设置的rect设置label的frameUILabel
UILabel *label = [[UILabel alloc]initWithFrame:CGRectMake(0,0,labelRect.size.width,labelRect.size.height)];
label.text = str;
label.font
= [UIFont systemFontOfSize:13];
[self.view addSubview:label];
网友评论