UI编程_UILabel及其属性

来源:互联网 发布:如何写bat文件运行java 编辑:程序博客网 时间:2024/04/28 07:59
////  AppDelegate.m//  UI01_UILabel////  Created by dllo on 15/7/10.//  Copyright (c) 2015年 dllo. All rights reserved.//#import "AppDelegate.h"@interface AppDelegate ()@end@implementation AppDelegate- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];    // Override point for customization after application launch.    self.window.backgroundColor = [UIColor whiteColor];    [self.window makeKeyAndVisible];    #pragma  mark - 知识点2 UILabel        /* 创建label对象 */    UILabel *userLabel = [[UILabel alloc] initWithFrame:CGRectMake(40, 100, 300, 200)];    userLabel.backgroundColor = [UIColor yellowColor];    [self.window addSubview:userLabel];            /* 设置相关的属性(常用API), attribute text调研 */    userLabel.text = @"用户名户名用户名名用名:";        /* font 属性, UIFont类, 调研一下(如何更改字体, 如何加载第三方字体) */    userLabel.font = [UIFont systemFontOfSize:26];        /* 文本颜色 调研一下(自定义颜色)*/    userLabel.textColor = [UIColor darkGrayColor];        /* 对齐方式 */    userLabel.textAlignment = NSTextAlignmentRight;        /* 断行模式(省略) */    userLabel.lineBreakMode = NSLineBreakByTruncatingMiddle;        /* 行数设置(设置为0:不受行数限制, 并且不会超过labele的限制) */    userLabel.numberOfLines = 0;        /* 阴影设置 */    userLabel.shadowColor = [UIColor redColor];    userLabel.shadowOffset = CGSizeMake(0, 2);                [userLabel release];    [_window release];    return YES;}@end

0 0