UI3_UILabel
//
// AppDelegate.m
// UI3_UILabel
//
// Created by zhangxueming on 15/6/29.
// Copyright (c) 2015年 zhangxueming. All rights reserved.
// #import "AppDelegate.h" @interface AppDelegate () @end @implementation AppDelegate - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//UILabel 继承与 UIView
//用来显示文字, 不可以编辑
UILabel *label1 = [[UILabel alloc] initWithFrame:CGRectMake(10, 100, self.window.frame.size.width-20, 50)];
//把label1添加到window上显示
[self.window addSubview:label1];//默认颜色是clearColor
//修改背景颜色
label1.backgroundColor = [UIColor cyanColor];
//设置文本
label1.text = @"千锋教育";
//设置文字对齐方式
//NSTextAlignmentLeft 居左对齐
//NSTextAlignmentCenter 居中对齐
//NSTextAlignmentRight 居右对齐
label1.textAlignment = NSTextAlignmentCenter;//居中对齐 //设置文字颜色
label1.textColor = [UIColor redColor]; //设置文字阴影偏移位置
label1.shadowOffset = CGSizeMake(5, -5);
label1.shadowColor = [UIColor blackColor]; //设置高亮状态颜色
label1.highlighted = NO;//设置文字的高亮状态
label1.highlightedTextColor = [UIColor blueColor]; UILabel *label2 = [[UILabel alloc] initWithFrame:CGRectMake(10, 200, self.window.frame.size.width-20, 100)];
label2.backgroundColor = [UIColor yellowColor];
label2.text = @"hello world hello world hello world hello world hello world hello world hello world hello world hello worldhello world中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国中国helloworld";
label2.textAlignment = NSTextAlignmentCenter;
//自适应字体宽度
label2.adjustsFontSizeToFitWidth = YES;
label2.minimumScaleFactor = 0.0;
//NSLineBreakByTruncatingHead
//NSLineBreakByTruncatingTail(默认)
//NSLineBreakByTruncatingMiddle
label2.lineBreakMode = NSLineBreakByTruncatingMiddle; //NSLineBreakByCharWrapping-->以字符截断换行
//NSLineBreakByWordWrapping-->以单词截断换行
//NSLineBreakByClipping-->剪裁多余的文本内容
label2.numberOfLines = 0;//numberOfLines=0 显示多行
label2.lineBreakMode = NSLineBreakByClipping;// UILabel *label3 = [[UILabel alloc] initWithFrame:CGRectMake(10, 350, self.window.frame.size.width-20, 50)];
label3.backgroundColor = [UIColor cyanColor];
[self.window addSubview:label3];
label3.text = @"中国教育-hello world";
label3.textAlignment = NSTextAlignmentCenter;
label3.textColor = [UIColor blueColor]; //默认字体大小是17
//设置字体大小
label3.font = [UIFont boldSystemFontOfSize:30]; //遍历字体库
//获取所有的字体簇
NSArray *familyFonts =[UIFont familyNames]; for (NSString *familyName in familyFonts) {
//获取字体簇所有的字体
NSArray *fonts = [UIFont fontNamesForFamilyName:familyName];
for (NSString *fontName in fonts) {
NSLog(@"name = %@", fontName);
}
} label3.font = [UIFont fontWithName:@"SnellRoundhand-Bold" size:24]; [self.window addSubview:label2]; self.window.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = nil;
return YES;
}
UI3_UILabel的更多相关文章
随机推荐
- Maven实战之Quick Start
Introduction Maven是一个异常强大的构建工具,能够帮我们自动化构建过程,从清理.编译.测试到生成报告,再到打包和部署.通过Maven,我们只需要输入简单的命令(如mvn clean i ...
- WCF入门教程(二)从零做起
通过最基本的操作看到最简单的WCF如何实现的.这是VS的SDK默认创建的样本 1.创建WCF服务库 2.看其生成结构 1)IService1.cs(协议) 定义了协议,具体什么操作,操作的参数和返回值 ...
- QoS 测量 (目标,方法,协议)
本文翻译自ITU-T的Technical Paper:<How to increase QoS/QoE of IP-based platform(s) to regionally agreed ...
- 安装jasperwave出错
1.错误描写叙述 2.错误原因 无法下载"com.jasperwave.engine_1.1.0.jar",须要又一次下载 3.解决的方法 将"com.jasperwav ...
- 基于css3的文字3D翻转特效
一款基于css3的文字3D翻转特效.这款特效当鼠标经过文字的时候3D翻转显示阴影.效果图如下: 在线预览 源码下载 实现的代码. html代码: <div class="compo ...
- 如何编写自己的Linux安全检查脚本?
因为本人工作中要涉及到很多东西,审计(日志.数据神马的).源代码审计.渗透测试.开发一大堆东西,有些东西,越是深入去做,越会发现,没有工具或脚本,工作起来是有多么的坑. 工作的这段时间,自己写了几个工 ...
- 美国H1B基本情况及相关数据
H-1B是外国人在美国工作的签证,从美国学校毕业之后会有12个月的OPT实习期,在OPT结束之前必须申请到H1B签证才能在实习期结束后继续工作. H1B需要由雇佣你的公司帮你申请,也就是说必须先找到工 ...
- Maximum repetition substring 后缀数组
Maximum repetition substring Time Limit: 1000MS Memory Limit: 65536K Total Submissions: 7578 Acc ...
- Bus Pass
ZOJ Problem Set - 2913 Bus Pass Time Limit: 5 Seconds Memory Limit: 32768 KB You travel a lot b ...
- 爬虫入门scrapy
Python之路[第十九篇]:爬虫 网络爬虫(又被称为网页蜘蛛,网络机器人,在FOAF社区中间,更经常的称为网页追逐者),是一种按照一定的规则,自动地抓取万维网信息的程序或者脚本.另外一些不常使用 ...