#import "ViewController.h"

@implementation ViewController

- (void)viewDidLoad {

[super viewDidLoad];

// 1.

UILabel *label = [[UILabel alloc] init];

// 1.1 text

label.text = @"//  ViewController.m01-UILabelCreated byjiaguanglei on 15/9/30Copyright (c) 2015年 roseonly. All rights reserved.";

// 1.2 font

/**

const CGFloat UIFontWeightUltraLight;

const CGFloat UIFontWeightThin;

const CGFloat UIFontWeightLight;

const CGFloat UIFontWeightRegular;

const CGFloat UIFontWeightMedium;

const CGFloat UIFontWeightSemibold;

const CGFloat UIFontWeightBold;

const CGFloat UIFontWeightHeavy;

const CGFloat UIFontWeightBlack;

+ (UIFont *)systemFontOfSize:(CGFloat)fontSize;

+ (UIFont *)boldSystemFontOfSize:(CGFloat)fontSize;   -- 粗体

+ (UIFont *)italicSystemFontOfSize:(CGFloat)fontSize; -- 斜体

+ (UIFont *)systemFontOfSize:(CGFloat)fontSize weight:(CGFloat)weight NS_AVAILABLE_IOS(8_2);

*/

label.font = [UIFont systemFontOfSize:20 weight:UIFontWeightBlack];

// 1.3 textColor

label.textColor = [UIColor magentaColor];

// 1.4 shadowColor

label.shadowColor = [UIColor greenColor];

// 1.5 shadowOffset

label.shadowOffset = CGSizeMake(2, 2);

// 1.6 textAlignment

/**

NSTextAlignmentLeft      = 0,    // Visually left aligned

NSTextAlignmentCenter    = 1,    // Visually centered

NSTextAlignmentRight     = 2,    // Visually right aligned

NSTextAlignmentJustified = 3,   // Fully-justified. The last line in a paragraph is natural-aligned.

NSTextAlignmentNatural   = 4,  // Indicates the default alignment for script

*/

label.textAlignment = NSTextAlignmentLeft;

// 1.7 lineBreakMode

/**  --- 设置换行格式

*  with long lines

NSLineBreakByWordWrapping = 0, --- 以单词为单位, 自动换行, 显示不全, 没有省略号

NSLineBreakByCharWrapping --- 以字符为单位自动换行, 没有省略号

NSLineBreakByClipping     --- 直接切除, 可能显示半个字符

NSLineBreakByTruncatingHead --- 在行头部, 显示省略号

NSLineBreakByTruncatingTail --- 在行尾部, 显示省略号

NSLineBreakByTruncatingMiddle --- 在行中间, 显示省略号

*/

label.lineBreakMode = NSLineBreakByTruncatingTail;

// 1.8 highlighted

// 1.8.1 highlightedTextColor

label.highlighted = NO;

label.highlightedTextColor = [UIColor blackColor];

// 1.9 enabled

// 1.9.1 userInteractionEnabled

label.enabled = YES;

label.userInteractionEnabled = YES;

// 1.10 numberOfLines

label.numberOfLines = 0;

// 1.11 adjustsFontSizeToFitWidth

label.adjustsFontSizeToFitWidth = YES;

// 1.11.1 adjustsLetterSpacingToFitWidth  --  已过期, 用NSKernAttributeName替换

// 1.11.2 minimumFontSize  --- --  已过期, 用minimumScaleFactor替代

label.minimumScaleFactor = .8;

// 1.11.3 baselineAdjustment

/**

UIBaselineAdjustmentAlignBaselines = 0, // default.

UIBaselineAdjustmentAlignCenters,

UIBaselineAdjustmentNone,

*/

label.baselineAdjustment = UIBaselineAdjustmentNone;

// 1.12 -- 绘图中可能会用到

/**

- (CGRect)textRectForBounds:(CGRect)bounds limitedToNumberOfLines:(NSInteger)numberOfLines;

- (void)drawTextInRect:(CGRect)rect;

@property(nonatomic) CGFloat preferredMaxLayoutWidth NS_AVAILABLE_IOS(6_0);

*/

// 1.13 attributedText

NSDictionary *attrs = @{NSForegroundColorAttributeName : [UIColor redColor]};

NSAttributedString *attrString = [[NSAttributedString alloc] initWithString:label.text attributes:attrs];

label.attributedText = attrString;

CGSize size = [UIScreen mainScreen].bounds.size;

label.frame = CGRectMake(10, 100, size.width - 20, 50);

label.backgroundColor = [UIColor lightGrayColor];

[self.view addSubview:label];

}

文档学习 - UILabel - 属性详解的更多相关文章

  1. elasticsearch系列三:索引详解(分词器、文档管理、路由详解(集群))

    一.分词器 1. 认识分词器  1.1 Analyzer   分析器 在ES中一个Analyzer 由下面三种组件组合而成: character filter :字符过滤器,对文本进行字符过滤处理,如 ...

  2. 一个完整的WSDL文档及各标签详解

    <?xml version="1.0" encoding="UTF8" ?> <wsdl:definitions targetNamespac ...

  3. 使用vs code编写Markdown文档以及markdown语法详解

    首先安装vscode工具,下载地址如下: https://code.visualstudio.com/ 在vs code的扩展中安装: Markdown Preview Enhanced 这款插件,安 ...

  4. MongoDB开发深入之一:文档数据关系模型详解(一对多,多对多)

    文档关联模型通常有3种方式: 嵌入式(一对一.一对多) 后期手动统一ID处理(一对多.多对多) References引用(一对一.一对多) 文档树模型通常有3种方式: 父引用(Parent Refer ...

  5. 轻松学习Linux之Shell文件和目录属性详解

    轻松学习Linux之Shell文件和目录属性详解 轻松学习Linux之理解Sitcky 轻松学习Linux之理解umask 轻松学习Linux之理解SUID&SGUID 本系列多媒体教程已完成 ...

  6. 第15.10节 PyQt(Python+Qt)入门学习:Qt Designer可视化设计界面组件与QWidget类相关的组件属性详解

    PyQt学习有阵子了,对章节的骨架基本考虑好了,准备本节就写组件的属性的,结果一是日常工作繁忙,经常晚上还要加班,二是Qt的组件属性很多,只能逐一学习.研究和整理,花的时间有点长,不过终于将可视化设计 ...

  7. Android零基础入门第80节:Intent 属性详解(下)

    上一期学习了Intent的前三个属性,本期接着学习其余四个属性,以及Android系统常用内置组件的启动. 四.Data和Type属性 Data属性通常用于向Action属性提供操作的数据.Data属 ...

  8. OutputCache属性详解(一)一Duration、VaryByParam

    目录 OutputCache概念学习 OutputCache属性详解(一) OutputCache属性详解(二) OutputCache属性详解(三) OutputCache属性详解(四)— SqlD ...

  9. OutputCache属性详解(三)— VaryByHeader,VaryByCustom

    目录 OutputCache概念学习 OutputCache属性详解(一) OutputCache属性详解(二) OutputCache属性详解(三) OutputCache属性详解(四)— SqlD ...

随机推荐

  1. 自定义QT事件

    qtuserclass 1.事件ID 本质上就是一个整型值.0-999作为系统保留字段,自定义事件从QEvent::User(也就是1000)开始, 例如: #define MY_EVENT QEve ...

  2. iOS之苹果和百度地图的使用

    iOS中使用较多的3款地图,google地图.百度地图.苹果自带地图(高德).其中苹果自带地图在中国使用的是高德的数据.苹果在iOS 6之后放弃了使用谷歌地图,而改用自家的地图.在国内使用的较多的就是 ...

  3. gdal和python在windows上的安装

    GDAL is a useful command line tool to process spatial data, if you haven’t heard of the tool before ...

  4. bootstrap.css.map这个文件有何用处?该怎能使用它?

    . ├── bootstrap.css ├── bootstrap.css.map ├── bootstrap.min.css ├── bootstrap-theme.css ├── bootstra ...

  5. JBPM WEB CONSOLE安装实录

    http://www.blogjava.net/paulwong/archive/2009/03/13/259551.html JBPM WEB CONSOLE是一个B/S端的,能管理JBPM的流程和 ...

  6. 时空分割的画面--用xcode命令行回忆turbo c

    大学时期曾经玩过turbo c的同学,可以用xcode命令行写写c程序,回味一下吧:) 1. 首先在终端输入,touch main.c 新建文件 2. 编辑main.c内容,写一段简单代码 #incl ...

  7. 04_XML_04_XMLDTD语法

    [DTD语法约束细节] * 元素定义 * 属性定义 * 实体定义 [1.元素定义] 在DTD文档中使用ELEMENT声明一个XML元素,语法格式如下所示: <!ELEMENT   元素名称  元 ...

  8. struts导包

    我用的是struts-2.2.3,开始把全部的jar包都放进去了,可是一直报 信息: Parsing configuration file [struts-plugin.xml]2011-6-11 8 ...

  9. HTML XML XHTML DHTML区别与联系

    (1)HTML HTML是超文本标记语言 (2)XML XML是可扩展标识语言,但XML是一种能定义其他语言的语. XML最初设计的目的是弥补HTML的不足, 以强大的扩展性满足网络信息发布的需要 , ...

  10. ubuntu 基本操作(1)

    命令行界面与图形界面 全屏模式: ctrl + alt + f1进入命令行界面 ctrl + alt + f7 切换图形界面 小窗口: ctrl+alt+t:进入终端 设计ubuntu root 密码 ...