//
// 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的更多相关文章

随机推荐

  1. 防止IE缓存jquery ajax 内容

    转自:http://blog.163.com/haijun_huang/blog/static/167591377201201235754763/ 解决办法: 方法一:把type改成post,并随便设 ...

  2. Android横竖屏切换及其相应布局载入问题

    第一.横竖屏切换连带载入多屏布局问题: 假设要让软件在横竖屏之间切换.因为横竖屏的高宽会发生转换,有可能会要求不同的布局. 能够通过下面两种方法来切换布局: 1)在res文件夹下建立layout-la ...

  3. andorid

    js内存泄露 三分面加七分水 —— 十分糊涂 膝盖上打瞌睡 —— 自己靠自己 不当家,不知柴米贵:不生子,不知父母恩. 水落现石头,日久见人心. sqllite http://wenku.baidu. ...

  4. Linux服务器集群系统(四)--转

    引用地址:http://www.linuxvirtualserver.org/zh/lvs4.html LVS集群的负载调度 章文嵩 (wensong@linux-vs.org) 2002 年 5 月 ...

  5. apt-mirror is already running(已运行)错误解决方案

    运行sudo apt-mirror却无法启动服务了.而是给出了一行错误提示信息:               apt-mirror is already running, exiting at /us ...

  6. 解决ntfs格式的移动硬盘mount到Linux下时变成只读文件系统的问题

    环境介绍 主机: XP 虚拟机:VirtualBox+Debian6 遇到的问题 我有一块西部数据的移动硬盘,虚拟机中有一些资料需要拷贝到移动硬盘中,然后我将移动硬盘插上后,执行如下设置,将移动硬盘分 ...

  7. 请谨慎使用 @weakify 和 @strongify

    来源:酷酷的哀殿 链接:http://www.jianshu.com/p/d8035216b257 前言 相信大部分见过 @weakify 和 @strongify 的开发者都会喜欢上这两个宏.但是很 ...

  8. C# mvc--EF中查询的本质

    UI层我直接用了窗体程序. 好了 不罗嗦 直接上代码…… private void button1_Click(object sender, EventArgs e) { //1.0创建EF上下文容器 ...

  9. 通用链表实现(参考Linux List)

    最近参考Linux实现的通用双向链表时,因typeof并不是标准c规定的关键字,除GCC编译器外其他编译器未必支持typeof关键字,所以在使用上并不能想Linux所实现的链表哪样灵活,它要求将连接器 ...

  10. [Java] 模拟HTTP的Get和Post请求

    在之前,写了篇Java模拟HTTP的Get和Post请求的文章,这篇文章起源与和一个朋友砍飞信诈骗网站的问题,于是动用了Apache的comments-net包,也实现了get和post的http请求 ...