您的位置:首页 > 产品设计 > UI/UE

UITabBarController和UINavigationController搭配使用

2016-08-05 14:52 453 查看
    self.window = [[UIWindow
alloc]initWithFrame:[UIScreen
mainScreen].bounds];
    
    
    ViewController *vc = [[ViewController
alloc]init];
    UINavigationController *nvc = [[UINavigationController
alloc]initWithRootViewController:vc];
    [vc.navigationItem
setTitle:@"第一页"];
    [vc.tabBarItem
setTitle:@"Message"];
    [vc.tabBarItem
setImage:[UIImage
imageNamed:@"message.png"]];
    
    [vc.tabBarItem
setBadgeValue:@"99+"];
    //设置字体颜色
    [vc.tabBarItem
setTitleTextAttributes:@{NSFontAttributeName:[UIFont
systemFontOfSize:20],NSForegroundColorAttributeName:[UIColor
whiteColor]}
forState:UIControlStateNormal];
   [vc.tabBarItem
setTitleTextAttributes:@{NSFontAttributeName:[UIFont
systemFontOfSize:20],NSForegroundColorAttributeName:[UIColor
blackColor]}
forState:UIControlStateHighlighted];
    [vc.view
setBackgroundColor:[UIColor
blueColor]];
    
    
    SecondViewController *svc = [[SecondViewController
alloc]init];
    UINavigationController *snvc = [[UINavigationController
alloc]initWithRootViewController:svc];
    [svc.navigationItem
setTitle:@"第一页"];
    [svc.tabBarItem
setTitle:@"Setting"];
    [svc.tabBarItem
setImage:[UIImage
imageNamed:@"setting.png"]];
    [svc.tabBarItem
setBadgeValue:@"999+"];
    [svc.view
setBackgroundColor:[UIColor
yellowColor]];
    
    UITabBarController *tb = [[UITabBarController
alloc]init];
    tb.viewControllers =
@[nvc,snvc];
    [tb.tabBar
setTintColor:[UIColor
redColor]];
    [tb.tabBar
setBarTintColor:[UIColor
orangeColor]];

    
    
    [self.window
setRootViewController:tb];
    [self.window
makeKeyAndVisible];
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: