//
// 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. [程序猿入行必备]CSS样式之优先级

    专业玩家请移步:http://www.w3.org/TR/CSS2/cascade.html 使用CSS控制页面样式时,常常出现设定的样式被"覆盖",不能生效的情况. 浏览器是根据 ...

  2. SharedObject使用:在FluorineFx.net与Flex中使用共享对象维护在线用户列表实例【转】

    一.添加一个新的FluorineFx的服务类项目OnLineService,删除原有的Sample.cs,并添加一个用户类定义与一个ApplicationAdpater类:如下: /*-- User. ...

  3. Cocos2d-x v3.0 新的事件调度方法 lambda表达式的使用

    欢迎添� Cocos2d-x 交流群: 193411763 转载请注明原文出处:http://blog.csdn.net/u012945598/article/details/24603251 Coc ...

  4. Maven项目报错:The superclass "javax.servlet.http.HttpServlet" was not found on the Java Build Path

    刚刚新建完Maven项目,一般都会报这个错误,原因是没有默认添加需要的javax.servelet的jar包,所以打开pom.xml文件添加如下dependency即可: <dependency ...

  5. Java SimpleDateFormat 函数

    一.SimpleDateFormat函数例子: SimpleDateFormat format=new SimpleDateFormat("MM-dd HH:mm:ss E"); ...

  6. Windows 之 win10快捷键

    1.Windows10系统常用快捷键: 1)贴靠窗口(窗口可以变为1/4大小放置在屏幕4个角落):Win +左/右 或 Win +上/下 2)切换窗口:Alt + Tab 3)任务视图(松开键盘界面不 ...

  7. A problem is easy

    描述When Teddy was a child , he was always thinking about some simple math problems ,such as “What it’ ...

  8. 用英文加优先级来解读C的声明

    比如:int ( * func_p ) ( double ); 首先着眼于标识符. func_p is 因为存在括号,(* func_p) 先被处理,这里着眼于* func_p is a pointe ...

  9. OC之property和自动释放池

    property实例 property参数 自动释放池 一.property实例 1.前边的例子我们看到,我们在一个类中如果用到另外一个类的实例作为自己的成员变量时,通常需要在setter方法中,先r ...

  10. 【MongoDB】MongoDB VS SQL数据库

    MongoDB和SQL数据库都能满足数据库的基本功能:1.有组织的存放数据:2.按照需求查询数据 传统的SQL数据库(e.g.Oracle, MySQL) 对表的运用不够灵活,横向扩展不太容易,而它的 ...