創建工程
整理工程
修改啓動頁
自定義App入口
#pragma mark - 程序啓動的時候就會調用
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
//1.創建窗口
self.window = [[UIWindow alloc] initWithFrame: [UIScreen mainScreen].bounds];
//2.設置窗口跟控制器
ViewController *tabBarVc = [[ViewController alloc] init];
self.window.rootViewController = tabBarVc;
//3.顯示窗口 -> 成爲UIApplication主窗口
[self.window makeKeyAndVisible];
return YES;
}
修改UIViewController背景色:
self.view.backgroundColor = [UIColor blueColor];
自定義UITabBarController
- 使用富文本格式自定義UITabBarItem選中的樣式
//獲取哪個類中UITabBarItem
UITabBarItem *item = [UITabBarItem appearanceWhenContainedIn:self, nil];
//設置按鈕選中標題的顏色:富文本:描述一個文字顏色,字體,陰影,空心,圖文混排
//創建一個描述文本屬性的字典
NSMutableDictionary *attrs = [NSMutableDictionary dictionary];
attrs[NSForegroundColorAttributeName] = [UIColor blackColor];
[item setTitleTextAttributes:attrs forState:UIControlStateSelected];
//設置字體尺寸:只有設置正常狀態下,纔會有效果
NSMutableDictionary *attrsNor = [NSMutableDictionary dictionary];
attrsNor[NSFontAttributeName] = [UIFont systemFontOfSize:13];
[item setTitleTextAttributes:attrsNor forState:UIControlStateNormal];
- 將UIViewController包裝成UINavigationController
WJZEssenceViewController *essenceVc = [[WJZEssenceViewController alloc] init];
//包裝成UINavigationController
UINavigationController *essenceNavVc = [[UINavigationController alloc] initWithRootViewController:essenceVc];
//添加子控制器
[self addChildViewController:essenceNavVc];
- 自定義TabBar
#pragma mark - 自定義tabBar
- (void)setupTabBar{
WJZTabBar *tabBar = [[WJZTabBar alloc] init];
[self setValue:tabBar forKey:@"tabBar"];
}
- 配置pch文件