Hibit_iOS/HiBit/Project/Publics/Controllers/HBTabBarController.m
2024-06-07 18:10:32 +08:00

87 lines
3.4 KiB
Objective-C

//
// HBTabBarController.m
// QinJiuTV
//
// Created by 秦九 on 2024/4/28.
//
#import "HBTabBarController.h"
#import "HBNavigationController.h"
#import "HBMineViewController.h"
#import "HBDiscoverViewController.h"
#import "HBHomeViewController.h"
@interface HBTabBarController ()
@end
@implementation HBTabBarController
///Users/loser/Documents/COMPANY/秦九科技/Project/HiBit/Pods/IGListKit/Source/IGListKit/Internal/IGListBatchUpdates.m Build input file cannot be found: '/Users/loser/Documents/COMPANY/秦九科技/Project/HiBit/Pods/IGListKit/Source/IGListKit/Internal/IGListBatchUpdates.m'. Did you forget to declare this file as an output of a script phase or custom build rule which produces it?
- (void)viewDidLoad {
[super viewDidLoad];
[self loadTabbar];
[self loadSubControllers];
}
- (void)loadTabbar {
UIColor * tabbarBackgroundColor = UIColor.blackColor;
if (@available (iOS 15.0, *)) {
// iOS 15.0 及以上
UITabBarAppearance *appearance = [[UITabBarAppearance alloc] init];
[appearance configureWithOpaqueBackground];
appearance.backgroundColor = tabbarBackgroundColor;
self.tabBar.standardAppearance = appearance;
self.tabBar.scrollEdgeAppearance = self.tabBar.standardAppearance;
} else {
self.tabBar.barTintColor = tabbarBackgroundColor;
}
self.tabBar.tintColor = HBColor.color_FF0049;
self.tabBar.unselectedItemTintColor = HBColor.color_999999;
}
- (void)loadSubControllers {
HBHomeViewController * homeController = [[HBHomeViewController alloc]init];
[self addChildViewController:homeController
title:[@"tabbar_home" language]
image:[UIImage imageNamed:@"tabbar_home_normal" renderingMode:UIImageRenderingModeAlwaysOriginal]
selectedImage:[UIImage imageNamed:@"tabbar_home_selected" renderingMode:UIImageRenderingModeAlwaysOriginal]];
HBDiscoverViewController * discoverController = [[HBDiscoverViewController alloc]init];
[self addChildViewController:discoverController
title:[@"tabbar_discover" language]
image:[UIImage imageNamed:@"tabbar_discover_normal" renderingMode:UIImageRenderingModeAlwaysOriginal]
selectedImage:[UIImage imageNamed:@"tabbar_discover_selected" renderingMode:UIImageRenderingModeAlwaysOriginal]];
HBMineViewController * mineController = [[HBMineViewController alloc]init];
[self addChildViewController:mineController
title:[@"tabbar_mine" language]
image:[UIImage imageNamed:@"tabbar_mine_normal" renderingMode:UIImageRenderingModeAlwaysOriginal]
selectedImage:[UIImage imageNamed:@"tabbar_mine_selected" renderingMode:UIImageRenderingModeAlwaysOriginal]];
}
- (void)addChildViewController:(UIViewController *)childController title:(NSString *)title image:(UIImage *)image selectedImage:(UIImage *)selectedImage {
childController.tabBarItem.title = title;
[childController.tabBarItem setImage:image];
[childController.tabBarItem setSelectedImage:selectedImage];
HBNavigationController * navigationController = [[HBNavigationController alloc]initWithRootViewController:childController];
[self addChildViewController:navigationController];
}
@end