UILabel详解
来源:互联网 发布:linux cdrom 编辑:程序博客网 时间:2024/06/06 04:26
- #import "LabelTestViewController.h"
- @implementation LabelTestViewController
- /*
- Accessing the Text Attributes
- text property
- font property
- textColor property
- textAlignment property
- lineBreakMode property
- enabled property
- Sizing the Label’s Text
- adjustsFontSizeToFitWidth property
- baselineAdjustment property
- minimumFontSize property 无例
- numberOfLines property
- Managing Highlight Values
- highlightedTextColor property
- highlighted property
- Drawing a Shadow
- shadowColor property
- shadowOffset property
- Drawing and Positioning Overrides
- – textRectForBounds:limitedToNumberOfLines: 无例
- – drawTextInRect: 无例
- Setting and Getting Attributes
- userInteractionEnabled property
- */
- // Implement viewDidLoad to do additional setup after loading the view, typically from a nib.
- - (void)viewDidLoad {
- UILabel *label1 = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 20.0, 200.0, 50.0)];
- UILabel *label2 = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 80.0, 200.0, 50.0)];
- UILabel *label3 = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 140.0, 200.0, 50.0)];
- UILabel *label4 = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 200.0, 200.0, 50.0)];
- UILabel *label5 = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 260.0, 200.0, 50.0)];
- UILabel *label6 = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 320.0, 200.0, 50.0)];
- UILabel *label7 = [[UILabel alloc]initWithFrame:CGRectMake(50.0, 380.0, 200.0, 50.0)];
- //设置显示文字
- label1.text = @"label1";
- label2.text = @"label2";
- label3.text = @"label3--label3--label3--label3--label3--label3--label3--label3--label3--label3--label3--";
- label4.text = @"label4--label4--label4--label4--";
- label5.text = @"label5--label5--label5--label5--label5--label5--";
- label6.text = @"label6";
- label7.text = @"label7";
- //设置字体
- label1.font = [UIFont boldSystemFontOfSize:20];
- //设置文字颜色
- label1.textColor = [UIColor orangeColor];
- label2.textColor = [UIColor purpleColor];
- //设置文字位置
- label1.textAlignment = UITextAlignmentRight;
- label2.textAlignment = UITextAlignmentCenter;
- //设置字体大小适应label宽度
- label4.adjustsFontSizeToFitWidth = YES;
- //设置label的行数
- label5.numberOfLines = 2;
- //设置高亮
- label6.highlighted = YES;
- label6.highlightedTextColor = [UIColor orangeColor];
- //设置阴影
- label7.shadowColor = [UIColor redColor];
- label7.shadowOffset = CGSizeMake(1.0,1.0);
- //设置是否能与用户进行交互
- label7.userInteractionEnabled = YES;
- //设置label中的文字是否可变,默认值是YES
- label3.enabled = NO;
- //设置文字过长时的显示格式
- label3.lineBreakMode = UILineBreakModeMiddleTruncation;//截去中间
- // typedef enum {
- // UILineBreakModeWordWrap = 0,
- // UILineBreakModeCharacterWrap,
- // UILineBreakModeClip,//截去多余部分
- // UILineBreakModeHeadTruncation,//截去头部
- // UILineBreakModeTailTruncation,//截去尾部
- // UILineBreakModeMiddleTruncation,//截去中间
- // } UILineBreakMode;
- //如果adjustsFontSizeToFitWidth属性设置为YES,这个属性就来控制文本基线的行为
- label4.baselineAdjustment = UIBaselineAdjustmentNone;
- // typedef enum {
- // UIBaselineAdjustmentAlignBaselines,
- // UIBaselineAdjustmentAlignCenters,
- // UIBaselineAdjustmentNone,
- // } UIBaselineAdjustment;
- UILabel 详解
- UILabel详解
- UILabel详解
- UILabel 详解
- UILabel 详解
- UILabel详解
- UILabel详解
- UILabel详解
- UILabel 详解
- UILabel详解
- UILabel 详解
- uilabel 详解
- UILabel详解
- UILabel 详解
- UILabel详解
- UILabel详解
- UIlabel详解
- UILabel详解
- 门户站基础css样式命名、应用原则和部分门户站的全局CSS
- Oracle小知识总结
- Flash 命令大全
- spring动态加载hibernate
- 【IOS功能实现】之 获取各种文件的目录路径的方法
- UILabel详解
- java笔记【九】
- hibernate get load区别 hibernate的生命周期
- jsp 常用标签库
- Lucene之MinShouldMatchScorer算法源码分析
- makefile for ffmpeg
- 织梦如何开启邮箱验证并设定发送内容
- 关于bash
- 我的通用底层架构。