UI04-標簽試圖控制器(UITabBarController)

AppDelegate.m

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
    self.window = [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor = [UIColor whiteColor];
    [self.window makeKeyAndVisible];
    
    UITabBarController *tabBarController = [[UITabBarController alloc] init];
    FirstViewController *firstViewController = [[FirstViewController alloc] init];
    firstViewController.title = @"首頁";
    UIImage *image = [UIImage imageNamed:@"4-selected@2x.png"];
    image = [image imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    UIImage *selectImage = [UIImage imageNamed:@"4-nomal@2x.png"];
    selectImage = [selectImage imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
    firstViewController.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"首頁" image:image selectedImage:selectImage];
   UINavigationController *firseNavigaton = [[UINavigationController alloc] initWithRootViewController:firstViewController];
    
    SecondViewController *secondViewController = [[SecondViewController alloc] init];
    secondViewController.title = @"我的";
    
    tabBarController.viewControllers = @[firseNavigaton,secondViewController];
    self.window.rootViewController = tabBarController;
     //tabBar屬性
    tabBarController.tabBar.tintColor = [UIColor blackColor];
    //tabBarController.tabBar.barTintColor = [UIColor greenColor];
    //不透明
    tabBarController.tabBar.translucent = NO;

    return YES;
}

UITabBarController 就是像微信下面的(我的、發現、通訊錄、首頁)這類的東西,基本上的App都有這個,大家要熟練應用哦

最后編輯于
?著作權歸作者所有,轉載或內容合作請聯系作者
平臺聲明:文章內容(如有圖片或視頻亦包括在內)由作者上傳并發布,文章內容僅代表作者本人觀點,簡書系信息發布平臺,僅提供信息存儲服務。

推薦閱讀更多精彩內容

  • Android 自定義View的各種姿勢1 Activity的顯示之ViewRootImpl詳解 Activity...
    passiontim閱讀 173,288評論 25 708
  • 發現 關注 消息 iOS 第三方庫、插件、知名博客總結 作者大灰狼的小綿羊哥哥關注 2017.06.26 09:4...
    肇東周閱讀 12,241評論 4 61
  • 敖若悠閱讀 272評論 0 0
  • 回家的途中,因為太困便靠在公交座椅上睡覺了,不經意間手肘觸碰到了鄰座男生的臂膀,大概持續了十幾秒,溫暖的感覺在周遭...
    柳絮風閱讀 258評論 0 0
  • 什么是URL URL是統一定位符,對可以從互聯網上得到的資源的位置和訪問方法的一種簡潔的表示,是互聯網上標準資源的...
    LeeoZz閱讀 230評論 0 0