• UISB 分栏控制器


    scenedelegate.m

    #import "SceneDelegate.h"
    #import "VCFirst.h"
    #import "VCSecond.h"
    #import "VCThird.h"
    @interface SceneDelegate ()
    
    @end
    
    @implementation SceneDelegate
    
    
    - (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
        self.window = [[UIWindow alloc] initWithWindowScene:(UIWindowScene *)scene];
        self.window.frame = CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, [UIScreen mainScreen].bounds.size.height);
        
        [self.window makeKeyAndVisible];
        
        VCFirst* vcFirst=[[VCFirst alloc]init];
        vcFirst.view.backgroundColor=[UIColor blueColor];
        
        
        VCSecond* vcSecond=[[VCSecond alloc]init];
        vcSecond.view.backgroundColor=[UIColor redColor];
        
        VCThird* vcThird=[[VCThird alloc]init];
        
        
        vcFirst.title=@"视图一";
        vcSecond.title=@"视图二";
        vcThird.title=@"视图三";
        vcThird.view.backgroundColor=[UIColor yellowColor];
    
        
    //    创建试图控制器
        UITabBarController* tbController=[[UITabBarController alloc]init];
    //    创建视图控制器数组
    //    将所有分栏控制器加到数组中
        NSArray* arrayVC=[NSArray arrayWithObjects:vcFirst,vcSecond,vcThird, nil];
    //    将分栏控制器管理数组赋值
        tbController.viewControllers=arrayVC;
    //    将分栏控制器为根视图控制器
        self.window.rootViewController=tbController;
    //    设置选中视图控制器的索引
        tbController.selectedIndex=2;
        
        
        if(tbController.selectedViewController==vcThird){
            NSLog(@"当前显示的视图控制器三");
            
        }
    //    设置透明度
        tbController.tabBar.translucent=NO;
        
        
    }

    VCSecond.m

    //
    
    #import "VCSecond.h"
    
    @interface VCSecond ()
    
    @end
    
    @implementation VCSecond
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
        UITabBarItem* tabBarItem = [[UITabBarItem alloc]initWithTabBarSystemItem:UITabBarSystemItemDownloads tag:101];
        
        
        self.tabBarItem=tabBarItem;
        
        
        
    }

    VCThird.m

    #import "VCThird.h"
    
    @interface VCThird ()
    
    @end
    
    @implementation VCThird
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        // Do any additional setup after loading the view.
        UIBarButtonItem* taBarItem=[[UITabBarItem alloc]initWithTitle:@"111" image:nil tag:101];
        
        self.tabBarItem=taBarItem;
        
    }
  • 相关阅读:
    Java_基础_内存管理
    Reflux中文教程——action
    Reflux中文教程——概览
    包含块、层叠上下文、BFC
    DOM编程的性能问题
    JavaScript数据存取的性能问题
    闭包
    JavaScript中的继承
    JavaScript中的静态成员
    JavaScript中的私有属性
  • 原文地址:https://www.cnblogs.com/zhangqing979797/p/13747279.html
Copyright © 2020-2023  润新知