SceneDelegate.m
- (void)scene:(UIScene *)scene willConnectToSession:(UISceneSession *)session options:(UISceneConnectionOptions *)connectionOptions {
// Use this method to optionally configure and attach the UIWindow `window` to the provided UIWindowScene `scene`.
// If using a storyboard, the `window` property will automatically be initialized and attached to the scene.
// This delegate does not imply the connecting scene or session are new (see `application:configurationForConnectingSceneSession` instead).
UIWindowScene *windowScene = (UIWindowScene *)scene;
self.window = [[UIWindow alloc] initWithWindowScene:windowScene];
self.window.frame = windowScene.coordinateSpace.bounds;
UITabBarController *tabBarController = [[UITabBarController alloc] init];
UIViewController *controller1 = [[UIViewController alloc] init];
controller1.view.backgroundColor = [UIColor redColor];
controller1.tabBarItem.title = @"Tab1";
controller1.tabBarItem.image = [UIImage imageNamed:@"icon.bundle/home"];
controller1.tabBarItem.selectedImage = [UIImage imageNamed:@"icon.bundle/home_selected"];
UIViewController *controller2 = [[UIViewController alloc] init];
controller2.view.backgroundColor = [UIColor yellowColor];
controller2.tabBarItem.title = @"Tab2";
controller2.tabBarItem.image = [UIImage imageNamed:@"icon.bundle/video"];
controller2.tabBarItem.selectedImage = [UIImage imageNamed:@"icon.bundle/video_selected"];
UIViewController *controller3 = [[UIViewController alloc] init];
controller3.view.backgroundColor = [UIColor blueColor];
controller3.tabBarItem.title = @"Tab3";
controller3.tabBarItem.image = [UIImage imageNamed:@"icon.bundle/like"];
controller3.tabBarItem.selectedImage = [UIImage imageNamed:@"icon.bundle/like_selected"];
UIViewController *controller4 = [[UIViewController alloc] init];
controller4.view.backgroundColor = [UIColor greenColor];
controller4.tabBarItem.title = @"Tab4";
controller4.tabBarItem.image = [UIImage imageNamed:@"icon.bundle/page"];
controller4.tabBarItem.selectedImage = [UIImage imageNamed:@"icon.bundle/page_selected"];
[tabBarController setViewControllers: @[controller1, controller2, controller3, controller4]];
tabBarController.tabBar.backgroundColor = [UIColor whiteColor];
self.window.rootViewController = tabBarController;
[self.window makeKeyAndVisible];
}