搜索
您的当前位置:首页正文

UILabel 标签

来源:哗拓教育

pragma mark UILabel 标签

// 创建一个Label,标签,它主要的作用是用来呈现文字内容
UILabel *myLabel = [[UILabel alloc]initWithFrame:CGRectMake(30, 30, 200, 100)];
myLabel.text = @"Landing landing landing landing landing landing landing landing";
// 设置label的实际行数,前提是高度得够,当行数为零时,当前文字会根据高度自动换行。
myLabel.numberOfLines = 2;
// 设置折行方式
myLabel.lineBreakMode = NSLineBreakByCharWrapping;
// 设置字体大小
myLabel.font = [UIFont systemFontOfSize:15];
// 得到系统的所有字体类型
NSArray *font = [UIFont familyNames];
NSLog(@"%@",font);
// 设置字体样式
myLabel.font = [UIFont fontWithName:@" Zapfino" size:15];
// 设置文字位置
myLabel.textAlignment = NSTextAlignmentCenter;

/**
 *  NSLineBreakByWordWrapping = 0,按照单词换行,默认用这个
 NSLineBreakByCharWrapping,按照字符换行
 NSLineBreakByClipping,基本不用
 NSLineBreakByTruncatingHead,省略号在前段
 NSLineBreakByTruncatingTail,省略号在末尾
 NSLineBreakByTruncatingMiddle省略号在中间
 */

// 设置背景颜色
myLabel.backgroundColor = [UIColor orangeColor];
// 设置文字颜色
myLabel.textColor = [UIColor yellowColor];
// 设置字体阴影
myLabel.shadowColor = [UIColor purpleColor];
// 设置阴影大小
myLabel.shadowOffset = CGSizeMake(3, 2);

[self.window addSubview:myLabel];

//// 显示图片的视图
// UIImageView *myImageView = [[UIImageView alloc]initWithFrame:[UIScreen mainScreen].bounds];
//// myImageView.backgroundColor = [UIColor redColor];
// [self.window addSubview:myImageView];
//
// UIImage *image = [UIImage imageNamed:@"1.png"];
// myImageView.image = image;
//
//// [self.window sendSubviewToBack:myImageView];
//
// [self.window exchangeSubviewAtIndex:2 withSubviewAtIndex:0];

UIImageView *image = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"1.png"]];
image.frame = [UIScreen mainScreen].bounds;
[self.window addSubview:image];
Top