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

UI2_UILabel

2015-10-20 20:30 441 查看

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];
[_window release];

**UILabel**

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

// 能显示文本内容
label.text = @"测试一下,aaaa.aafjskwevdsfcds的的的的的fc的";
// 给label加上一个边框,并且给它加上一个弧度
label.layer.borderWidth = 1;
label.layer.cornerRadius = 10;

*隐藏多余部分*
// 让label多余的部分隐藏掉
label.layer.masksToBounds = YES;
// 修改字体大小
label.font = [UIFont systemFontOfSize:25];
// 修改文字颜色
label.textColor = [NSColor cyanColor];
// 对齐方式
label.textAlignment = NSTextAlignmentCenter;

// 设置行数
label.numberOfLines = NSIntegerMax;
// 可以自动适应文本内容
[label sizeToFit];

// 阴影颜色和大小
label.shadowColor = [UIColor redColor];
label.shadowOffset = CGSizeMake(2, 2);
label.center = CGPointMake(100, 100);

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