• 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
  • 相关阅读:
    UESTC cdoj 619 吴神,人类的希望 (组合数学)
    Codeforces Round #317 (Div. 2) D Minimization (贪心+dp)
    Codeforces Round #317 div2 E div1 C CNF 2 (图论,匹配)
    Codeforces Round #317 (Div. 2) C Lengthening Sticks (组合,数学)
    UVA 1412 Fund Management (预处理+状压dp)
    UVA
    codeforces Gym 100338F Spam Filter 垃圾邮件过滤器(模拟,实现)
    WebSocket 学习教程(二):Spring websocket实现消息推送
    dwr的ScriptSession和HttpSession分析
    WebSocket 学习教程(一):理论
  • 原文地址:https://www.cnblogs.com/zhangqing979797/p/13466641.html
Copyright © 2020-2023  润新知