zoukankan      html  css  js  c++  java
  • 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;
        
    }
  • 相关阅读:
    ndk安装
    android studio安装
    navicat15安装及激活
    relative和absolute理解
    meta标签大全
    爆炸、翻转、扭曲、立方、翻页特效
    CSS3-多媒体查询
    CSS3-按钮
    CSS3-图片
    css3-多列
  • 原文地址:https://www.cnblogs.com/zhangqing979797/p/13747279.html
Copyright © 2011-2022 走看看