h文件里:
// AppDelegate.h
// LesssonUILabel_AM_6.24
//
// Created by lanouhn on 15/6/24.
// Copyright (c) 2015年 . All rights reserved.
//
#import
@interface AppDelegate : UIResponder <</span>UIApplicationDelegate>
@property (retain, nonatomic) UIWindow *window;
@end
m文件里:
//
// AppDelegate.m
// LesssonUILabel_AM_6.24
//
// Created by lanouhn on 15/6/24.
// Copyright (c) 2015年. All rights reserved.
//
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (void)dealloc{
[_window release];
[super dealloc];
}
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
self.window = [[[UIWindow alloc] initWithFrame:[[UIScreenmainScreen] bounds]] autorelease];
// Override point for customization after application launch.
self.window.backgroundColor = [UIColor whiteColor];
[self.window makeKeyAndVisible];
//UILabel -- UILabel是UIView的子类, 也是视图;UILabel的使用步骤和UIView类似 只是UILabel多了一个显示文本 (字符串) 的功能 而且 UILabel的属性是与文本显示有关的
//UILabel 1.创建对象
UILabel *textLabel = [[UILabel alloc]initWithFrame:CGRectMake(20, 100, 315, 80)];
//设置属性 2.设置一个颜色
textLabel.backgroundColor = [UIColor yellowColor];
//3.设置text 显示的文字
textLabel.text = @"you can you up , nocannobibi";
//4.设置文本里字符串的颜色 textColor
textLabel.textColor = [UIColor redColor];
//5.修改字体的大小 systemFontOfSize 修改字体的大小
textLabel.font = [UIFont systemFontOfSize:30];
//boldSystemFontOfSize修改字体的大小, 同时将字体加粗
//textLabel.font = [UIFont boldSystemFontOfSize:20];
//获取所有字体的样式
//NSLog(@"%@",[UIFont familyNames]);
//修改字体
//textLabel.font = [UIFont fontWithName: @" Zapfino" size:20];
//6.文本的对齐方式 左对齐 右对齐 居中对齐
//textLabel.textAlignment = NSTextAlignmentCenter;
//textLabel.textAlignment = NSTextAlignmentRight;
//7.设置文本多行显示 前提是文字的大小以及文本框的高度能够达到我们多行显示字体的要求 (高度得够)
//numberOfLines == 0 0代表多行显示 (会根据当前字体的大小和UILabel视图的高度来决定显示几行,如果自提大的话, 则不能够完全显示)
textLabel.numberOfLines = 0;
//8.根据当前内容的多少来自动适应字体的大小以至于文本能够完全显示
// textLabel.adjustsFontSizeToFitWidth = YES;
//9.设置文本显示的阴影颜色
textLabel.shadowColor = [UIColor blackColor];
//10.设置音译ing的偏移量 CGSizeMake(1, 1)第一个参数是往x轴方向偏移的单位 第二个参数是往y轴方向的偏移单位
textLabel.shadowOffset = CGSizeMake(10, 10);
//11.字符串的截取方式
//NSLineBreakByWordWrapping 以单词为标准截取
//NSLineBreakByCharWrapping 以字符为标准来截取
textLabel.lineBreakMode = NSLineBreakByWordWrapping;
textLabel.lineBreakMode = NSLineBreakByCharWrapping;
//12.修改视图的形状
//是否截掉边角
textLabel.layer.masksToBounds = YES;
//截取边角的半径
textLabel.layer.cornerRadius = 30;
//设计边框的宽度
textLabel.layer.borderWidth = 8;
//设计边框的颜色
textLabel.layer.borderColor = [UIColor redColor].CGColor;
// //添加到父视图上
[self.window addSubview:textLabel];
//释放所有权
[textLabel release];
return YES;
}
- (void)applicationWillResignActive:(UIApplication*)application {
// Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
// Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game.
}
- (void)applicationDidEnterBackground:(UIApplication*)application {
// Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
// If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
}
- (void)applicationWillEnterForeground:(UIApplication*)application {
// Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background.
}
- (void)applicationDidBecomeActive:(UIApplication*)application {
// Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface.
}
- (void)applicationWillTerminate:(UIApplication *)application {
// Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}
@end