标签:
下面的语句都是我亲自试验过的,保证可以运行出来。
UILabel *label = [[UILabel alloc] init];
NSString *text = @"这是一个测试!!";
label.text = text;
label.numberOfLines = 0;
UIFont *font = [UIFont systemFontOfSize:14];
label.backgroundColor = [UIColor greenColor];
//设置字体
label.font = font;
CGSize constraint = CGSizeMake(300, 20000.0f);
CGSize size = [text sizeWithFont:font constrainedToSize:constraint lineBreakMode:UILineBreakModeWordWrap];
[label setFrame:CGRectMake(10, 0, size.width, size.height)];
[self.view addSubview:label];
UILabel *label1 = [[UILabel alloc]init];
label1.numberOfLines = 0;
UIFont *font1 = [UIFont systemFontOfSize:17];
label1.font = font1;
label1.backgroundColor = [UIColor greenColor];
label1.text = @"原来这少年是张浩然的堂哥,比张浩然早一步加入流云宗,以前他也参加过闯木人巷比赛,可惜排在三十名开外,距离前十名差的很远,更不要说第三名了,这次若是能取得第三名,一本人级高阶功法秘籍是少不了的,还能得到一本人级高阶武技秘籍和三枚清风yù1ù丸,足够他修炼到凝真境层次";
CGSize constraint1 = CGSizeMake(365, 99999);
CGSize size1 = [label1.text sizeWithFont:font1 constrainedToSize:constraint1 lineBreakMode:UILineBreakModeWordWrap];
label1.frame = CGRectMake(10, 50, size1.width, size1.height);
[self.view addSubview:label1];
标签:
原文地址:http://www.cnblogs.com/lmg4819/p/4800711.html