创建工程
整理工程
修改启动页
自定义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文件