您的位置:首页 > 产品设计 > UI/UE

UI编程_UILabel及其属性

2015-07-10 19:56 405 查看
//
//  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
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  UILabel ui iOS iPhone