zoukankan      html  css  js  c++  java
  • UI基础 UITabBarController

    app.m

    #import "AppDelegate.h"
    #import "TmailViewController.h"
    #import "TaoBaoViewController.h"
    @interface AppDelegate ()
    
    @end
    
    @implementation AppDelegate
    
    
    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
        self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];
        // Override point for customization after application launch.
        self.window.backgroundColor = [UIColor whiteColor];
        [self.window makeKeyAndVisible];
        
        //淘宝页面
        TaoBaoViewController *taobao =[[TaoBaoViewController alloc] init];
        
        UINavigationController *taoNav=[[UINavigationController alloc] initWithRootViewController:taobao];
        
        
        //设置标题
        taoNav.tabBarItem.title=@"淘宝";
        //设置未选中的图片
        taoNav.tabBarItem.image=[UIImage imageNamed:@"taobao"];
        
        //设置选中时的图片
        taoNav.tabBarItem.selectedImage=[UIImage imageNamed:@"taobao"];
        
        
        
        //天猫页面
        TmailViewController *tmall =[[TmailViewController alloc] init];
        
        UINavigationController *tmallNav=[[UINavigationController alloc]initWithRootViewController:tmall];
        
        
        
        //设置标题
        tmallNav.tabBarItem.title=@"天猫";
        //设置未选中的图片
        tmallNav.tabBarItem.image=[UIImage imageNamed:@"tianmao"];
        //设置选中时的图片
        tmallNav.tabBarItem.selectedImage=[UIImage imageNamed:@"tianmao"];
        
        //统一设置导航栏的格式
        [[UINavigationBar appearance] setBarTintColor:[UIColor greenColor]];
        [[UINavigationBar appearance] setTranslucent:NO];
        
        
        
        
        UITabBarController *tabbarC =[[UITabBarController alloc]init];
        // 将页面放在tabbarcontroller 中
        tabbarC.viewControllers= [NSArray arrayWithObjects:taoNav,tmallNav,nil];
        //把tabbarcontroller 作为window的根视图
        self.window.rootViewController =tabbarC;
      
        
        return YES;
    }

    taobao.m

    #import "TaoBaoViewController.h"
    
    @interface TaoBaoViewController ()
    
    @end
    
    @implementation TaoBaoViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        self.view.backgroundColor=[UIColor blueColor];
        
        self.navigationItem.title=@"淘宝";
    
    }
    
    
    
    @end

    tmail.m

    #import "TmailViewController.h"
    
    @interface TmailViewController ()
    
    @end
    
    @implementation TmailViewController
    
    - (void)viewDidLoad {
        [super viewDidLoad];
        self.view.backgroundColor=[UIColor yellowColor];
        self.navigationItem.title=@"天猫";
    
    }
    
    
    @end
  • 相关阅读:
    各种版本控制器的作用
    mybatis的一些特殊符号标识(大于,小于,等于,不等于)
    struts2的作用是什么
    js中给数组添加元素的方法有哪些
    springmvc中拦截器配置格式
    js中require()的用法----JS如何连接数据库执行sql语句或者建立数据库连接池
    hover()函数的用法
    error和exception的不同与相同
    cookie和session的区别有哪些
    数据库连接池的工作机制是什么
  • 原文地址:https://www.cnblogs.com/zhangqing979797/p/13466641.html
Copyright © 2011-2022 走看看