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
  • 相关阅读:
    FormsAuthentication 简单使用
    2.0 泛型
    解决Eclipse java build path中Web App Libraries无法自动找到WEBINF的lib目录
    WinHex 15.8 r4 注册信息
    用ClassPathXmlApplicationContext读取Spring配置文件的路径问题
    Installing NFS on CentOS 6.2
    使用XStream对Java对象进行序列化和反序列化
    Eclipse代码注释模板code template
    Timestamp和String的相互转换 Java
    visual studio vs2010 2012 C/C++ 编译找不到mspdb100.dll文件的解决方法
  • 原文地址:https://www.cnblogs.com/zhangqing979797/p/13466641.html
Copyright © 2011-2022 走看看