AppDelegate.h
#import <UIKit/UIKit.h>
// 按位枚举
typedef NS_ENUM(NSUInteger, NetType) {
NONet = 1 << 0,
NetTwoG = 1 << 1,
NetWlan = 1 << 2,
};
@interface AppDelegate : UIResponder <UIApplicationDelegate>
@property (strong, nonatomic) UIWindow *window;
@end
AppDelegate.m
#import "AppDelegate.h"
@interface AppDelegate ()
@end
@implementation AppDelegate
- (void)dealloc {
[_window release];
[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];
// 按照4步, 来创建一个UILabel
UILabel *label = [[UILabel alloc] initWithFrame:CGRectMake(100, 100, 150, 50)];
label.backgroundColor = [UIColor yellowColor];
[self.window addSubview:label];
[label release];
// 能显示文本内容
label.text = @"我是一只伯符鸟fdasgagaglk卡的结论是覅哦啊嘎嘎骄傲阿哥i";
// 给label加上一个边框, 并且给它加上一个弧度
label.layer.borderWidth = 1;
label.layer.cornerRadius = 10;
// 让label多余的部分隐藏掉
label.layer.masksToBounds = YES;
// 修改字体大小
label.font = [UIFont systemFontOfSize:19];
#if 0
// 文字颜色
label.textColor = [UIColor redColor];
// 对齐方式
label.textAlignment = NSTextAlignmentCenter ;
// NSLog(@"%ld, %ld, %ld", NONet, NetTwoG, NetWlan);
#endif
// 设置行数
label.numberOfLines = NSIntegerMax;
// 可以自动适应文本内容
[label sizeToFit];
#warning 想要它能自己去适应, 必须先设置文本内容, 再设置行数和自适应
// 阴影颜色和大小
label.shadowColor = [UIColor blackColor];
// label.shadowOffset = CGSizeMake(5, 5);
label.center = CGPointMake(100, 100);
return YES;
}