菜鸟启航:UILabel基本操作
2015-09-06 19:09
106 查看
UILabel 文本
//样式定制
label.text =
@"hello world!";
label.textColor = [UIColor
redColor];
label.textAlignment =
NSTextAlignmentCenter;
label.backgroundColor = [UIColor
blueColor];
label.font = [UIFont
boldSystemFontOfSize:20];
label.shadowOffset =
CGSizeMake(10,
10);
label.shadowColor = [UIColor
yellowColor];
label.highlighted =
YES;
label.highlightedTextColor = [UIColor
greenColor];
label.numberOfLines =
0;
label.baselineAdjustment =
UIBaselineAdjustmentNone;
label.lineBreakMode =
NSLineBreakByCharWrapping;
//创建一个Label
UILabel * label = [[UILabel
alloc] initWithFrame:CGRectMake(60,
200, 200,
200)];
//给Label提供显示内容
label.text =
@"Yestory is history,and tomorrow is mystery,but taday is a gift,that's why it's call present";
//把Label显示到屏幕上。
//Labelf
//
label.backgroundColor = [UIColor
greenColor];
//修改Label的对齐模式
label.textAlignment =
NSTextAlignmentCenter;
//靠左 NSTextAlignmentLeft
//居中 NSTextAlignmentCenter
//靠右 NSTextAlignmentRight
label.font = [UIFont
systemFontOfSize:35];
// label.font = [UIFont italicSystemFontOfSize:30];
// label.font = [UIFont boldSystemFontOfSize:30];
// label.font = [UIFont fontWithName:@"Party LET" size:40];
NSArray * array = [UIFont
familyNames];
NSLog(@"%@",array);
//限制最多显示的行数
, 默认值是 1
label.numberOfLines =
10;
//换行模式
// label.lineBreakMode = NSLineBreakByCharWrapping;
// label.lineBreakMode = NSLineBreakByClipping;
// label.lineBreakMode = NSLineBreakByTruncatingHead;
// label.lineBreakMode = NSLineBreakByTruncatingMiddle;
label.lineBreakMode =
NSLineBreakByTruncatingTail;
// NSLineBreakByCharWrapping 按字符截断
// NSLineBreakByClipping 按单词换行
从末尾裁剪最后一行
// NSLineBreakByTruncatingHead 按单词换行,末尾一行从头开始删节
label.textColor = [UIColor
redColor];
//给文字添加阴影效果
label.shadowOffset =
CGSizeMake(5,
5);
label.shadowColor = [UIColor
blackColor];
//标记
不能赋值为0
label.tag =
10;
//字体大小
自适应内容
label.adjustsFontSizeToFitWidth =
YES;
label.minimumScaleFactor =
0.5;
[self.view
addSubview:label];
//样式定制
label.text =
@"hello world!";
label.textColor = [UIColor
redColor];
label.textAlignment =
NSTextAlignmentCenter;
label.backgroundColor = [UIColor
blueColor];
label.font = [UIFont
boldSystemFontOfSize:20];
label.shadowOffset =
CGSizeMake(10,
10);
label.shadowColor = [UIColor
yellowColor];
label.highlighted =
YES;
label.highlightedTextColor = [UIColor
greenColor];
label.numberOfLines =
0;
label.baselineAdjustment =
UIBaselineAdjustmentNone;
label.lineBreakMode =
NSLineBreakByCharWrapping;
//创建一个Label
UILabel * label = [[UILabel
alloc] initWithFrame:CGRectMake(60,
200, 200,
200)];
//给Label提供显示内容
label.text =
@"Yestory is history,and tomorrow is mystery,but taday is a gift,that's why it's call present";
//把Label显示到屏幕上。
//Labelf
//
label.backgroundColor = [UIColor
greenColor];
//修改Label的对齐模式
label.textAlignment =
NSTextAlignmentCenter;
//靠左 NSTextAlignmentLeft
//居中 NSTextAlignmentCenter
//靠右 NSTextAlignmentRight
label.font = [UIFont
systemFontOfSize:35];
// label.font = [UIFont italicSystemFontOfSize:30];
// label.font = [UIFont boldSystemFontOfSize:30];
// label.font = [UIFont fontWithName:@"Party LET" size:40];
NSArray * array = [UIFont
familyNames];
NSLog(@"%@",array);
//限制最多显示的行数
, 默认值是 1
label.numberOfLines =
10;
//换行模式
// label.lineBreakMode = NSLineBreakByCharWrapping;
// label.lineBreakMode = NSLineBreakByClipping;
// label.lineBreakMode = NSLineBreakByTruncatingHead;
// label.lineBreakMode = NSLineBreakByTruncatingMiddle;
label.lineBreakMode =
NSLineBreakByTruncatingTail;
// NSLineBreakByCharWrapping 按字符截断
// NSLineBreakByClipping 按单词换行
从末尾裁剪最后一行
// NSLineBreakByTruncatingHead 按单词换行,末尾一行从头开始删节
label.textColor = [UIColor
redColor];
//给文字添加阴影效果
label.shadowOffset =
CGSizeMake(5,
5);
label.shadowColor = [UIColor
blackColor];
//标记
不能赋值为0
label.tag =
10;
//字体大小
自适应内容
label.adjustsFontSizeToFitWidth =
YES;
label.minimumScaleFactor =
0.5;
[self.view
addSubview:label];
相关文章推荐
- Kbuild文件
- UICollectionView
- SpannableString与SpannableStringBuilder
- JPQL查询语句(Java Presistence Query Language)(转)
- 使用sql生成UUID
- iOS音频播放 (五):AudioQueue
- UE4 编译虚幻引擎
- hibernate中HQL查询count返回query取得其长度
- Arduino ULN2009驱动步进电机
- Java中的StringBuilder类功能详解
- java.lang.IllegalArgumentException: the bind value at index 1 is null or java.lang.IllegalArgumen
- UE4在VS2013中各个编译配置代表意义
- 全面解释java中StringBuilder、StringBuffer、String类之间的关系
- ios UIAlertView
- Android更新ui 的几种方式?Handler 机制(二)
- iOS9新特性 - UIStack View
- UI基础-01 隐藏键盘
- DuiLib : 执行按钮事件, 模拟按钮的点击
- UE4的编译配置详解
- Failed to run the WC DB work queue associated with 错误的解决