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;
}