• iOS开发学习笔记(OC语言)——底部tab栏


    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];
    }
    
  • 相关阅读:
    Linux下的vim简易配置与Windows下的vim配置
    ASP.NET MVC2(Visual Studio.NET 2010)学习之路(一)
    NonSQL
    完成公司核名
    调试iOS 已经发布代码 Crash 文件分析出出错对应代码
    iOS RSA公钥加密数据 服务端接受PHP私钥解密 反过服务端公钥加密数据 iOS端私钥解密数据
    iOS 日期格式串 setDateFormat 显示格式代码
    iOS5 UI 设计新手段 Storyboard
    UIEdgeInsets
    xcode调试找出错误行
  • 原文地址:https://www.cnblogs.com/lurenjiashuo/p/15892759.html
Copyright © 2020-2023  润新知