美文网首页
iOS开发之常用代码块

iOS开发之常用代码块

作者: LuckyBugGo | 来源:发表于2018-11-10 01:06 被阅读0次

持续更新中

设置TabBarController为Window的根视图

-(void)setupRootVCWithTabBarC{
    
    // 因为有多个页面,建议另写函数去设置
    UITabBarController *rootVC = [UITabBarController new];
    [rootVC setViewControllers:@[<#[self NVC_VCInstanceForTBC]#>] animated:YES];
    
    // Window大小设置为屏幕大小
    self.window = [[UIWindow alloc]initWithFrame:[[UIScreen mainScreen] bounds]];
    // 设置Window的根视图
    self.window.rootViewController = rootVC;
    // 将Window使能
    [self.window makeKeyAndVisible];

}

创建一个导航视图层级的TabBar子视图

-(UIViewController *)NVC_<#VC#>InstanceForTBC{
    
    <#UIViewController#> *vc1 = <#[UIViewController new]#>;
    // 设置标题
    vc1.tabBarItem.title = <#@"首页"#>;
    // 默认图标
    vc1.tabBarItem.image = <#[UIImage new]#>;
    // 选中图标
    vc1.tabBarItem.selectedImage = <#[UIImage new]#>;
    
    return [[UINavigationController alloc] initWithRootViewController:vc1];
}

相关文章

网友评论

      本文标题:iOS开发之常用代码块

      本文链接:https://www.haomeiwen.com/subject/lkwaxqtx.html