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

UI_UILabel

2015-07-30 08:31 211 查看
#import "AppDelegate.h"

@interface AppDelegate ()

@end

@implementation AppDelegate

- (void)dealloc
{
[_window release];
// 释放.h文件属性的retain
[super dealloc];
}

- (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];

[_window release];

UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100,
100, 150,
150)];
label.backgroundColor = [UIColor cyanColor];
[self.window addSubview:label];
[label release];

//
设置文本内容
label.text =
@"吟游诗人
守护
法师
血袭";

//
文本字体的颜色
label.textColor = [UIColor whiteColor];

//
文本的对齐方式
label.textAlignment = NSTextAlignmentCenter;

//
字体大小
label.font = [UIFont systemFontOfSize:20];

//
设置行数

//
默认是一行

//
设置成0是行数的最大值
label.numberOfLines =
3;

//
让文本自己去适应label的尺寸,显示全部内容

// [label sizeToFit];

//
断行模式
label.lineBreakMode = NSLineBreakByTruncatingMiddle;

//
阴影大小
label.shadowOffset = CGSizeMake(2,
1);

//
阴影颜色
label.shadowColor = [UIColor blackColor];

//
设置圆角和边框

//
设置边框
label.layer.borderWidth =
1;

//
设置圆角
label.layer.cornerRadius =
30;

//
去除多余的部分
label.layer.masksToBounds =
YES;

// center可以修改视图的位置

// label.frame = CGRectMake(100, 100, 200, 200);
label.center = CGPointMake(100 +
75, 100 +
75);

return
YES;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: