• 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;
        
    }
  • 相关阅读:
    Mobile phones(poj1195)
    Matrix(poj2155)
    1080
    1266
    codeforces626D . Jerry's Protest
    字符串格式化
    附加MySQL数据库的方法
    avaScript中变量的声明和赋值
    选择法排序
    JavaScript中变量的类型
  • 原文地址:https://www.cnblogs.com/zhangqing979797/p/13747279.html
Copyright © 2020-2023  润新知