处理tabbar

处理HomeRankContentVC去除弹性效果 - 适配HWPanModal下拉效果
This commit is contained in:
2025-11-06 19:29:52 +08:00
parent 6ba1339c0b
commit a72aae84ef
3 changed files with 61 additions and 7 deletions

View File

@@ -665,8 +665,10 @@
04FC95BF2EB1E3B1007BD342 /* Class */ = {
isa = PBXGroup;
children = (
047C65492EBCBA880035E841 /* Community */,
04FC95B62EB1E3B1007BD342 /* Home */,
047C654D2EBCBA880035E841 /* Shop */,
047C65492EBCBA880035E841 /* Community */,
04FC95BE2EB1E3B1007BD342 /* Me */,
047C652C2EBCAAAC0035E841 /* Resource */,
04FC95EE2EB3399D007BD342 /* Manager */,
04FC95ED2EB33611007BD342 /* Login */,
@@ -675,8 +677,6 @@
04FC95E12EB20AD1007BD342 /* Guard */,
04FC95C62EB1E4AB007BD342 /* Base */,
04FC95BA2EB1E3B1007BD342 /* Main */,
04FC95B62EB1E3B1007BD342 /* Home */,
04FC95BE2EB1E3B1007BD342 /* Me */,
);
path = Class;
sourceTree = "<group>";

View File

@@ -24,18 +24,43 @@
[super viewDidLoad];
[self setupTabbarAppearance];
// Setup two tabs: Home & My, each embedded in BaseNavigationController
// 4 Tab / / /
// Assets.xcassets/Tabbar tab_home/tab_home_selected
//
HomeMainVC *home = [[HomeMainVC alloc] init];
home.title = @"首页";
BaseNavigationController *navHome = [[BaseNavigationController alloc] initWithRootViewController:home];
navHome.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"首页" image:nil selectedImage:nil];
navHome.tabBarItem = [self tabItemWithTitle:@"首页"
image:@"tab_home"
selectedImg:@"tab_home_selected"];
//
KBShopVC *shop = [[KBShopVC alloc] init];
shop.title = @"商城";
BaseNavigationController *navShop = [[BaseNavigationController alloc] initWithRootViewController:shop];
navShop.tabBarItem = [self tabItemWithTitle:@"商城"
image:@"tab_shop"
selectedImg:@"tab_shop_selected"];
//
KBCommunityVC *community = [[KBCommunityVC alloc] init];
community.title = @"社区";
BaseNavigationController *navCommunity = [[BaseNavigationController alloc] initWithRootViewController:community];
navCommunity.tabBarItem = [self tabItemWithTitle:@"社区"
image:@"tab_shequ"
selectedImg:@"tab_shequ_selected"];
//
MyVC *my = [[MyVC alloc] init];
my.title = @"我的";
BaseNavigationController *navMy = [[BaseNavigationController alloc] initWithRootViewController:my];
navMy.tabBarItem = [[UITabBarItem alloc] initWithTitle:@"我的" image:nil selectedImage:nil];
navMy.tabBarItem = [self tabItemWithTitle:@"我的"
image:@"tab_my"
selectedImg:@"tab_my_selected"];
self.viewControllers = @[navHome, navMy];
self.viewControllers = @[navHome, navShop, navCommunity, navMy];
// Token
/*[[KBAuthManager shared] saveAccessToken:@"TEST" refreshToken:nil expiryDate:[NSDate dateWithTimeIntervalSinceNow:3600] userIdentifier:nil]*/;
@@ -48,11 +73,39 @@
UITabBarAppearance *a = [UITabBarAppearance new];
[a configureWithOpaqueBackground];
a.backgroundColor = [UIColor whiteColor];
// iOS 15+ appearance
NSDictionary *selAttr = @{ NSForegroundColorAttributeName : [UIColor blackColor] };
a.stackedLayoutAppearance.selected.titleTextAttributes = selAttr;
a.inlineLayoutAppearance.selected.titleTextAttributes = selAttr;
a.compactInlineLayoutAppearance.selected.titleTextAttributes = selAttr;
self.tabBar.standardAppearance = a;
self.tabBar.scrollEdgeAppearance = a;
} else if (@available(iOS 13.0, *)) {
UITabBarAppearance *a = [UITabBarAppearance new];
[a configureWithOpaqueBackground];
a.backgroundColor = [UIColor whiteColor];
NSDictionary *selAttr = @{ NSForegroundColorAttributeName : [UIColor blackColor] };
a.stackedLayoutAppearance.selected.titleTextAttributes = selAttr;
a.inlineLayoutAppearance.selected.titleTextAttributes = selAttr;
a.compactInlineLayoutAppearance.selected.titleTextAttributes = selAttr;
self.tabBar.standardAppearance = a;
self.tabBar.tintColor = [UIColor blackColor];
} else {
// tintColor/appearance 退
self.tabBar.tintColor = [UIColor blackColor];
[[UITabBarItem appearance] setTitleTextAttributes:@{NSForegroundColorAttributeName:[UIColor blackColor]}
forState:UIControlStateSelected];
}
}
// TabBarItem Tint
- (UITabBarItem *)tabItemWithTitle:(NSString *)title image:(NSString *)imageName selectedImg:(NSString *)selectedName {
UIImage *img = [[UIImage imageNamed:imageName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UIImage *sel = [[UIImage imageNamed:selectedName] imageWithRenderingMode:UIImageRenderingModeAlwaysOriginal];
UITabBarItem *item = [[UITabBarItem alloc] initWithTitle:title image:img selectedImage:sel];
return item;
}
/*
#pragma mark - Navigation

View File

@@ -76,6 +76,7 @@
_tableView = [[BaseTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
_tableView.dataSource = self;
_tableView.delegate = self;
_tableView.bounces = false;
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone; // 线
_tableView.showsVerticalScrollIndicator = NO;
_tableView.contentInset = UIEdgeInsetsMake(8, 0, KB_SafeAreaBottom(), 0);