无标题文章

2017-02-05  本文已影响6人  师景福

//需要判断是否登录

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];

上一篇 下一篇

猜你喜欢

热点阅读