//
// 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. Android 新浪微博代码

    新浪微博开发 [代码] android Weibo weibo=new Weibo(); weibo.setUserId("sdhjob@hotmail.com"); weibo. ...

  2. Android短信监听软件

    本案例是在android手机中运行,是一个没有界面的短信监听软件.主要是用BroadcastReceiver来接受短信广播,当接收到短信后就跳转到service中来转发短信.哈哈,不是用来干坏事的.这 ...

  3. LINUX 内存结构

    1.页框管理 Linux采用4KB页框大小作为标准的内存分配单元.内核必须记录每个页框的状态,这种状态信息保存在一个类型为page的页描述符中,所有的页描述存放在mem_map中.virt_to_pa ...

  4. 史上最详细版!java文件打包成exe,在未配置安装JDK和未配置的电脑上运行--转载

    原文地址:http://funine.iteye.com/blog/2220359 (本文所有素材将在文章最后附上) 准备工具exe4j, converticon.com(用于制做.ico格式的图片) ...

  5. C/C++的参数传递机制

    近来公司招人较多,由此面试了非常多的C++程序员.面试时,我都会问到参数传递的相关问题,尤其侧重指针.因为指针毕竟是C/C++最重要的一个优势(在某种情况下也可以说是劣势).但其结果是,1/3的人基本 ...

  6. F - Tree

    Description You are to determine the value of the leaf node in a given binary tree that is the termi ...

  7. Keywords Search

    Keywords Search Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) ...

  8. DIH

    DIH内存溢出: 在使用DIH时,容易报内存溢出错误.可以通过设置jvm大小来解决.设置方法如下: 在tomcat\bin\startup.bat 加入SET JAVA_OPTS=-Xms128m - ...

  9. iOS 真机测试的一些报错

    1.连了手机热点 fix Issue后出现提示框:No Devices Registered:Creating a provisioning profile requires one or more ...

  10. JAVA xml 流方式读取。数据挖掘大文件预处理。

    import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.Fi ...