UILabel *labTest = [[UILabel alloc] initWithFrame:CGRectMake(10, 10, 100, 30)];
//设置字体大小
labTest.font = [UIFont systemFontOfSize:14.0];
UIFont *font = [UIFont fontWithName:@"Helvetica" size:15.0];
[labTest setFont:font];
labTest.backgroundColor = [UIColor clearColor]; //清空背景色
labTest.textColor = [UIColor blueColor]; //设置字体颜色
labTest.textAlignment = UITextAlignmentRight; //设置对齐方式
labTest.adjustsFontSizeToFitWidth = YES; //设置字体大小是否适应label宽度
labTest.highlighted = YES; //设置是否是高亮
labTest.highlightedTextColor = [UIColor whiteColor]; //高亮颜色
labTest.shadowColor = [UIColor grayColor]; //设置阴影颜色
labTest.shadowOffset = CGSizeMake(0.5, 0.5); //阴影偏移量
labTest.userInteractionEnabled = YES; //是否能和用户交互
labTest.enabled = YES; //文字是否可变
labTest.lineBreakMode = UILineBreakModeHeadTruncation; //文字过长时的显示方式
[labTest setNumberOfLines:0]; //设置行数
//自适应大小
NSString *strText = @"啊啊啊啊啊啊啊啊啊了啦啦啦啦啦啦哦哦哦哦哦哦哦";
CGSize sizeTest = [strText sizeWithFont:font constrainedToSize:CGSizeMake(20.0f, 150.0f) lineBreakMode:UILineBreakModeWordWrap];
CGRect rect = labTest.frame;
rect.size = sizeTest;
[labTest setFrame:rect];
[labTest setText:strText];
//设置字体大小
labTest.font = [UIFont systemFontOfSize:14.0];
UIFont *font = [UIFont fontWithName:@"Helvetica" size:15.0];
[labTest setFont:font];
labTest.backgroundColor = [UIColor clearColor]; //清空背景色
labTest.textColor = [UIColor blueColor]; //设置字体颜色
labTest.textAlignment = UITextAlignmentRight; //设置对齐方式
labTest.adjustsFontSizeToFitWidth = YES; //设置字体大小是否适应label宽度
labTest.highlighted = YES; //设置是否是高亮
labTest.highlightedTextColor = [UIColor whiteColor]; //高亮颜色
labTest.shadowColor = [UIColor grayColor]; //设置阴影颜色
labTest.shadowOffset = CGSizeMake(0.5, 0.5); //阴影偏移量
labTest.userInteractionEnabled = YES; //是否能和用户交互
labTest.enabled = YES; //文字是否可变
labTest.lineBreakMode = UILineBreakModeHeadTruncation; //文字过长时的显示方式
[labTest setNumberOfLines:0]; //设置行数
//自适应大小
NSString *strText = @"啊啊啊啊啊啊啊啊啊了啦啦啦啦啦啦哦哦哦哦哦哦哦";
CGSize sizeTest = [strText sizeWithFont:font constrainedToSize:CGSizeMake(20.0f, 150.0f) lineBreakMode:UILineBreakModeWordWrap];
CGRect rect = labTest.frame;
rect.size = sizeTest;
[labTest setFrame:rect];
[labTest setText:strText];