UILabel *label1 = [[UILabel alloc]init];
label1.frame = CGRectMake(20, 20, 200, 200);
label1.backgroundColor = [UIColor yellowColor];
//文本
label1.text = @"hello,hello,hello,hello,hello,hello,hello,hello,hello,";
//文字颜色
label1.textColor = [UIColor blackColor];
//文字布局模式
label1.textAlignment = NSTextAlignmentLeft;
label1.alpha = 0.5f;
//设置字体
label1.font = [UIFont systemFontOfSize:30];
label1.font = [UIFont boldSystemFontOfSize:30];
label1.font = [UIFont italicSystemFontOfSize:30];
label1.font = [UIFont fontWithName:@"Didot" size:30]; //设置字体和字号
//设置阴影
label1.shadowColor = [UIColor grayColor];
label1.shadowOffset = CGSizeMake(1, 2);
//换行 labe要有足够空间
label1.lineBreakMode = NSLineBreakByWordWrapping; //换行模式
label1.numberOfLines = 10;
CGSize size = [label1.text sizeWithFont:label1.font constrainedToSize:CGSizeMake(200, 10000) lineBreakMode:NSLineBreakByWordWrapping];
label1.frame = CGRectMake(label1.frame.origin.x
, label1.frame.origin.y
, label1.frame.size.width, size.height);
[self.view addSubview:label1];
文本
label1.text =@"hello,hello,hello,hello,hello,hello,hello,hello,hello,";
文字颜色
label1.textColor = [UIColorblackColor];
文字布局模式
label1.textAlignment =NSTextAlignmentLeft;
label1.alpha =0.5f;
设置字体
label1.font = [UIFontsystemFontOfSize:30];
label1.font = [UIFontboldSystemFontOfSize:30];
label1.font = [UIFont thinSystemFontOfSize:30];
label1.font = [UIFontitalicSystemFontOfSize:30];
设置字体和字号
label1.font = [UIFontfontWithName:@"Didot"size:30];
设置阴影
label1.shadowColor = [UIColorgrayColor];
label1.shadowOffset =CGSizeMake(1,2);
换行 labe要有足够空间
label1.lineBreakMode =NSLineBreakByWordWrapping;//换行模式
label1.numberOfLines =10;
CGSize size = [label1.textsizeWithFont:label1.fontconstrainedToSize:CGSizeMake(200,10000) lineBreakMode:NSLineBreakByWordWrapping];
label1.frame =CGRectMake(label1.frame.origin.x
, label1.frame.origin.y
, label1.frame.size.width
, size.height);