iOS_OC_项目搭建

创建工程

在这里插入图片描述

整理工程

在这里插入图片描述
在这里插入图片描述

修改启动页

在这里插入图片描述

自定义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

  1. 使用富文本格式自定义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];
  1. 将UIViewController包装成UINavigationController
WJZEssenceViewController *essenceVc = [[WJZEssenceViewController alloc] init];
    //包装成UINavigationController
    UINavigationController *essenceNavVc = [[UINavigationController alloc] initWithRootViewController:essenceVc];
    //添加子控制器
    [self addChildViewController:essenceNavVc];
  1. 自定义TabBar
#pragma mark - 自定义tabBar
- (void)setupTabBar{
    WJZTabBar *tabBar = [[WJZTabBar alloc] init];
    [self setValue:tabBar forKey:@"tabBar"];
}
  1. 配置pch文件
    在这里插入图片描述
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章