UI第二讲(UILabel)

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 -- UILabelUIView的子类也是视图;UILabel的使用步骤和UIView类似  只是UILabel多了一个显示文本 (字符串的功能   而且  UILabel的属性是与文本显示有关的

   

    //UILabel   1.创建对象

    UILabel *textLabel = [[UILabel alloc]initWithFrame:CGRectMake(2010031580)];

    //设置属性  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(1010);

    //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


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值