iOS UILanel 一些小实用

UILabel *lab=[[UILabel alloc]initWithFrame:self.view.bounds];

//合并
lab.text=[NSString stringWithFormat:@"%@%@",@"coach: ","coache"];

//圆形
lab.layer.cornerRadius=num1.bounds.size.width/2;
lab.layer.masksToBounds=YES;

//换行,高度要足够才能换行
lab.lineBreakMode = NSLineBreakByWordWrapping;
lab.numberOfLines = 0;

//边框
lab.layer.borderColor = [UIColor colorWithRed:236.0f/255.0f green:235.0f/255.0f blue:240.0f/255.0f alpha:1].CGColor;//颜色
lab.layer.borderWidth = 3.0f;//设置边框粗细
lab.layer.masksToBounds = YES;

lab.textAlignment =  NSTextAlignmentCenter;//居中
lab.textAlignment = NSTextAlignmentLeft;//靠左
lab.textAlignment = NSTextAlignmentRight;//靠右

猜你喜欢

转载自www.cnblogs.com/sheer-code/p/10871429.html