当前位置: 代码迷 >> 综合 >> IOS开发(5)UITabBarController
  详细解决方案

IOS开发(5)UITabBarController

热度:87   发布时间:2024-01-05 12:08:56.0

代码方式创建UITabBarController

代码

    self.window = [[UIWindow alloc] initWithFrame:[[UIScreen mainScreen] bounds]];self.window.backgroundColor = [UIColor whiteColor];UITabBarController *tbc = [[UITabBarController alloc] init];UIStoryboard *sb = [UIStoryboard storyboardWithName:@"Storyboard" bundle:nil];OneController *one = [sb instantiateViewControllerWithIdentifier:@"one01"];one.tabBarItem.title = @"one";ViewController *two = [sb instantiateViewControllerWithIdentifier:@"view01"];two.tabBarItem.title = @"two";tbc.viewControllers = @[one , two];self.window.rootViewController = tbc;[self.window makeKeyAndVisible];return YES;

运行效果

运行效果