用闲暇时间总结一下以前学过的内容,介绍一下UILable的基础用法,还有一些没有写,以后会慢慢补充
- (void)viewDidLoad {
[super viewDidLoad];
UILabel *lable = [[UILabel alloc] initWithFrame:CGRectMake(0, 100, 300, 30)];//创建并设置坐标与大小
lable.text = @"hello World";//lable内的文字
lable.textColor = [UIColor redColor];//文字的颜色
lable.font = [UIFont systemFontOfSize:30];//改变字体大小
lable.textAlignment = NSTextAlignmentLeft;//左对齐
//NSTextAlignmentRight//右对齐
//NSTextAlignmentCenter//居中对齐
lable.numberOfLines = 3;//lable内的行数限制
lable.adjustsFontSizeToFitWidth = YES;//让文字适应文本框
//文字超出范围显示方式
lable.lineBreakMode = NSLineBreakByTruncatingHead;// ....ABCD
//NSLineBreakByTruncatingTail ABCD....
//NSLineBreakByTruncatingMiddle AB....CD
lable.backgroundColor = [UIColor cyanColor];//lable的背景颜色
lable.shadowColor = [UIColor yellowColor];//文本阴影颜色
lable.shadowOffset = CGSizeMake(1.0, 1.0);//阴影大小
[self.view addSubview:lable];
}
![奋斗](http://static.blog.csdn.net/xheditor/xheditor_emot/default/struggle.gif)
![奋斗](http://static.blog.csdn.net/xheditor/xheditor_emot/default/struggle.gif)
![奋斗](http://static.blog.csdn.net/xheditor/xheditor_emot/default/struggle.gif)