UI2_UILabel

来源:互联网 发布:苹果手机安装不了淘宝 编辑:程序博客网 时间:2024/04/30 15:13

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;}
0 0
原创粉丝点击