美文网首页
纯代码给tabBar设置UIViewController

纯代码给tabBar设置UIViewController

作者: 纯阳子_ | 来源:发表于2016-09-01 22:05 被阅读74次

    NSString *news = @"新闻";

    NewsViewController *newsVC = [[NewsViewController alloc] init];

    newsVC.title = news;

    UINavigationController *newNC = [[UINavigationController alloc] initWithRootViewController:newsVC];

    newNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:news image:[UIImage imageNamed:@"tabbar_icon_news_normal"] selectedImage:[UIImage imageNamed:@"tabbar_icon_news_highlight"]];

    NSString *reading = @"阅读";

    ReadViewController *readingTVC = [[ReadViewController alloc]init];

    readingTVC.title = reading;

    UINavigationController *readingNC = [[UINavigationController alloc] initWithRootViewController:readingTVC];

    readingNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:reading image:[UIImage imageNamed:@"tabbar_icon_reader_normal"] selectedImage:[UIImage imageNamed:@"tabbar_icon_reader_highlight"]];

    NSString *video = @"视听";

    ViewController *videoTVC = [[ViewController alloc]init];

    // videoTVC.title = video;

    UINavigationController *videoNC = [[UINavigationController alloc] initWithRootViewController:videoTVC];

    videoNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:video image:[UIImage imageNamed:@"tabbar_icon_media_normal"] selectedImage:[UIImage imageNamed:@"tabbar_icon_media_highlight"]];

    NSString *mine = @"我们";

    MineTableViewController *mineTVC = [[MineTableViewController alloc] initWithStyle:UITableViewStyleGrouped];

    mineTVC.title = mine;

    UINavigationController *mineNC = [[UINavigationController alloc] initWithRootViewController:mineTVC];

    mineNC.tabBarItem = [[UITabBarItem alloc] initWithTitle:mine image:[UIImage imageNamed:@"tabbar_icon_me_normal"] selectedImage:[UIImage imageNamed:@"tabbar_icon_me_highlight"]];

    self.viewControllers = @[newNC, readingNC, videoNC, mineNC];

    相关文章

      网友评论

          本文标题:纯代码给tabBar设置UIViewController

          本文链接:https://www.haomeiwen.com/subject/notokttx.html