iOS UINavigationBar + UITabBar

    //TabBar

    UITabBarController *tabBarCtrl = [[UITabBarController alloc]init];

    tabBarCtrl.tabBar.backgroundColor = [UIColor whiteColor];

    tabBarCtrl.tabBar.tintColor = [UIColor whiteColor];

    //navigationBar

    UINavigationController *nav = [[UINavigationController alloc]initWithRootViewController:tabBarCtrl];

    self.window.rootViewController = nav;

    //創建子控制器

    UIViewController *firstVC = [[UIViewController alloc]init];

    firstVC.tabBarItem.title = @"first";

    firstVC.tabBarItem.image = [UIImage imageNamed:@"1.png"];

    firstVC.view.backgroundColor = [[UIColor greenColor] colorWithAlphaComponent:0.9];

    firstVC.tabBarItem.selectedImage = [UIImage imageNamed:@"1.png"];

    

    UIViewController *secondVC = [[UIViewController alloc]init];

    secondVC.tabBarItem.title = @"first";

    secondVC.tabBarItem.image = [UIImage imageNamed:@"2.png"];

    secondVC.view.backgroundColor = [[UIColor greenColor] colorWithAlphaComponent:0.9];

    secondVC.tabBarItem.selectedImage = [UIImage imageNamed:@"2.png"];


    tabBarCtrl.viewControllers = @[firstVC,secondVC];

發佈了25 篇原創文章 · 獲贊 0 · 訪問量 4萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章