IOS - Lable基础用法
2016-01-14 15:48
429 查看
用闲暇时间总结一下以前学过的内容,介绍一下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];
}
既然选择了这个行业,就继续努力,大家一起加油
- (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];
}
既然选择了这个行业,就继续努力,大家一起加油
相关文章推荐
- iOS 星星评价视图 3行搞定
- iOS 隐藏导航栏或状态栏
- IOS #define和预编译指令
- iOSPush原理及实现
- 台式机与笔记本电脑BIOS启动热键
- iOS中json解析出现的null,nil,NSNumber的解决办法
- 【IOS】iOS 如何放大按钮点击热区
- IOS去除百度地图定位后的蓝色圆圈和定位蓝点(精度圈)
- iOS SDL2静态库的编译
- [IOS]edgesForExtendedLayout、automaticallyAdjustsScrollViewInsets、、
- 自学ios——基础篇
- IOS中输入框被软键盘遮挡的解决办法
- 苹果开发那些事儿-D-U-N-S 号申请
- Runtime系列Blog
- iOS歌词解析
- iOS崩溃调试的使用和技巧总结~
- iOS中属性与成员变量的区别
- iOS 检测更新
- iOS音乐播放器(歌词自动滚动)
- ios蓝牙开发(二)