内容自适应UILabel

xcode 6.1

File-New-Project..

iOs-Application-Simple View Application

内容自适应UILabel

代码:

- (void)viewDidLoad {
[super viewDidLoad]; UILabel *labelLoginname = [[UILabel alloc] initWithFrame:CGRectMake(,,,)];
//[labelLoginname setNumberOfLines:0];
NSString *s = @"账号:";
UIFont *font = [UIFont fontWithName:@"Arial" size:];
CGSize size = CGSizeMake(,); NSDictionary *attribute = @{NSFontAttributeName: [UIFont systemFontOfSize:]};
CGSize labelsize = [s boundingRectWithSize:size options: NSStringDrawingUsesFontLeading attributes:attribute context:nil].size; labelLoginname.frame = CGRectMake(80.0, 80.0, labelsize.width, labelsize.height);
labelLoginname.backgroundColor = [UIColor whiteColor];
labelLoginname.textColor = [UIColor blackColor];
labelLoginname.text = s;
labelLoginname.font = font; [self.view addSubview:labelLoginname];
}
上一篇:安装mysql.zip文件教程(包含常见问题修复)


下一篇:(实用篇)jQuery+PHP+MySQL实现二级联动下拉菜单