惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

L
LangChain Blog
阮一峰的网络日志
阮一峰的网络日志
WordPress大学
WordPress大学
博客园 - 司徒正美
罗磊的独立博客
D
Docker
Last Week in AI
Last Week in AI
爱范儿
爱范儿
M
MIT News - Artificial intelligence
V
V2EX
Google DeepMind News
Google DeepMind News
小众软件
小众软件
Apple Machine Learning Research
Apple Machine Learning Research
Microsoft Security Blog
Microsoft Security Blog
T
Tailwind CSS Blog
MyScale Blog
MyScale Blog
V
Visual Studio Blog
博客园 - 叶小钗
B
Blog RSS Feed
A
About on SuperTechFans
F
Fortinet All Blogs
T
The Blog of Author Tim Ferriss
Martin Fowler
Martin Fowler
P
Proofpoint News Feed

博客园 - 观海云不远

ChatView:把 ChatGPT / Claude 对话保存、分享和发布成独立网页 AI对普通人到底有什么用?这8个场景告诉你答案 用 AI 做点不一样的事:你出想法,我来实现 Python 调试工具PDB的基本使用 帮园子算账省钱 linux I/O性能优化 Linux内存问题排查工具 CPU优化方案 系统中出现大量不可中断进程和僵尸进程怎么办? CPU 使用率过高怎么办 CPU上下文切换 到底应该怎么理解“平均负载”? iOS开发学习笔记(OC语言)——block使用示例 iOS开发学习笔记(OC语言)——调起APP(URL Scheme) iOS开发学习笔记(OC语言)——文件基本操作 iOS开发学习笔记(OC语言)——网络请求 iOS开发学习笔记(OC语言)——线程安全的单例 iOS开发学习笔记(OC语言)——UIView和UIViewController生命周期 Jenkins安装配置回滚 Mac 下反编译Android APK
iOS开发学习笔记(OC语言)——底部tab栏
观海云不远 · 2022-02-14 · via 博客园 - 观海云不远

SceneDelegate.m

- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
    // Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
    // If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
    // This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
    
    UIWindowScene *windowScene = (UIWindowScene *)scene;
    self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
    self.window.frame = windowScene.coordinateSpace.bounds;
    
    UITabBarController *tabBarController = [[UITabBarController alloc] init];
    
    UIViewController *controller1 = [[UIViewController alloc] init];
    controller1.view.backgroundColor = [UIColor redColor];
    controller1.tabBarItem.title = @"Tab1";
    controller1.tabBarItem.image = [UIImage imageNamed:@"icon.bundle/home"];
    controller1.tabBarItem.selectedImage = [UIImage imageNamed:@"icon.bundle/home_selected"];
    
    UIViewController *controller2 = [[UIViewController alloc] init];
    controller2.view.backgroundColor = [UIColor yellowColor];
    controller2.tabBarItem.title = @"Tab2";
    controller2.tabBarItem.image = [UIImage imageNamed:@"icon.bundle/video"];
    controller2.tabBarItem.selectedImage = [UIImage imageNamed:@"icon.bundle/video_selected"];
    
    UIViewController *controller3 = [[UIViewController alloc] init];
    controller3.view.backgroundColor = [UIColor blueColor];
    controller3.tabBarItem.title = @"Tab3";
    controller3.tabBarItem.image = [UIImage imageNamed:@"icon.bundle/like"];
    controller3.tabBarItem.selectedImage = [UIImage imageNamed:@"icon.bundle/like_selected"];
    
    UIViewController *controller4 = [[UIViewController alloc] init];
    controller4.view.backgroundColor = [UIColor greenColor];
    controller4.tabBarItem.title = @"Tab4";
    controller4.tabBarItem.image = [UIImage imageNamed:@"icon.bundle/page"];
    controller4.tabBarItem.selectedImage = [UIImage imageNamed:@"icon.bundle/page_selected"];
    
    [tabBarController setViewControllers: @[controller1, controller2, controller3, controller4]];
    
    tabBarController.tabBar.backgroundColor = [UIColor whiteColor];
        
    self.window.rootViewController = tabBarController;
    [self.window makeKeyAndVisible];
}