//
// 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. linux C(hello world) 二维数组的练习

  2. 如何在XAF中显示自定义窗体和控件

    https://www.devexpress.com/Support/Center/Example/Details/E911

  3. 在Shell中使用函数文件

    需要编写一个较庞大的脚本时,可能会涉及许多函数.变量.这是通常建议将众多的函数.变量放入一个单独的脚本内.这样做的好处很明显,不用担心某个函数.变量是否已经被定义和使用,也不用频繁地定义.清除函数和变 ...

  4. GNU C/C++ __attributes__ GCC中的弱符号与强符号

    最近在看一些源代码,遇到了一些使用__attribute__修饰函数和变量的属性方面的代码,不是太了解,很是汗颜,再此做个总结:   GCC使用__attribute__关键字来描述函数,变量和数据类 ...

  5. Win7下安装Apache+PHP+phpMyAdmin+wordpress+drupal+discuz

    [Apache] Listen 90 DocumentRoot "C:/Program Files/Apache Software Foundation/Apache2.2/htdocs&q ...

  6. SQL Server 中的事务和锁(三)-Range S-U,X-X 以及死锁

    在上一篇中忘记了一个细节.Range T-K 到底代表了什么?Range T-K Lock 代表了在 SERIALIZABLE 隔离级别中,为了保护范围内的数据不被并发的事务影响而使用的一类锁模式(避 ...

  7. DIH

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

  8. oc语言复制视频文件

    void copyFile() { NSString *home=NSHomeDirectory(); NSString *path=[NSString stringWithFormat:@" ...

  9. [转]SVN:This client is too old to work with working copy 的解决方案

    前一段时间,我在Eclipse碰到一个SVN错误,出现的原因是我的Eclipse的SVN插件是1.6,服务器的SVN版本是1.5.4,然后我在工程目录下做了一次提交操作(不是Eclipse里),到最后 ...

  10. [Java] Eclipse+Spring学习(一)环境搭建

    转自:http://blog.sina.com.cn/s/blog_7c3736810100qhia.html 最近由于投了一家公司实习,他要java工程师,而我大学3年的精力都花到了ASP.NET和 ...