处理tabbar
处理HomeRankContentVC去除弹性效果 - 适配HWPanModal下拉效果
This commit is contained in:
@@ -665,8 +665,10 @@
|
|||||||
04FC95BF2EB1E3B1007BD342 /* Class */ = {
|
04FC95BF2EB1E3B1007BD342 /* Class */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
047C65492EBCBA880035E841 /* Community */,
|
04FC95B62EB1E3B1007BD342 /* Home */,
|
||||||
047C654D2EBCBA880035E841 /* Shop */,
|
047C654D2EBCBA880035E841 /* Shop */,
|
||||||
|
047C65492EBCBA880035E841 /* Community */,
|
||||||
|
04FC95BE2EB1E3B1007BD342 /* Me */,
|
||||||
047C652C2EBCAAAC0035E841 /* Resource */,
|
047C652C2EBCAAAC0035E841 /* Resource */,
|
||||||
04FC95EE2EB3399D007BD342 /* Manager */,
|
04FC95EE2EB3399D007BD342 /* Manager */,
|
||||||
04FC95ED2EB33611007BD342 /* Login */,
|
04FC95ED2EB33611007BD342 /* Login */,
|
||||||
@@ -675,8 +677,6 @@
|
|||||||
04FC95E12EB20AD1007BD342 /* Guard */,
|
04FC95E12EB20AD1007BD342 /* Guard */,
|
||||||
04FC95C62EB1E4AB007BD342 /* Base */,
|
04FC95C62EB1E4AB007BD342 /* Base */,
|
||||||
04FC95BA2EB1E3B1007BD342 /* Main */,
|
04FC95BA2EB1E3B1007BD342 /* Main */,
|
||||||
04FC95B62EB1E3B1007BD342 /* Home */,
|
|
||||||
04FC95BE2EB1E3B1007BD342 /* Me */,
|
|
||||||
);
|
);
|
||||||
path = Class;
|
path = Class;
|
||||||
sourceTree = "<group>";
|
sourceTree = "<group>";
|
||||||
|
|||||||
@@ -24,18 +24,43 @@
|
|||||||
[super viewDidLoad];
|
[super viewDidLoad];
|
||||||
|
|
||||||
[self setupTabbarAppearance];
|
[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];
|
HomeMainVC *home = [[HomeMainVC alloc] init];
|
||||||
home.title = @"首页";
|
home.title = @"首页";
|
||||||
BaseNavigationController *navHome = [[BaseNavigationController alloc] initWithRootViewController:home];
|
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];
|
MyVC *my = [[MyVC alloc] init];
|
||||||
my.title = @"我的";
|
my.title = @"我的";
|
||||||
BaseNavigationController *navMy = [[BaseNavigationController alloc] initWithRootViewController:my];
|
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
|
// 测试储存Token
|
||||||
/*[[KBAuthManager shared] saveAccessToken:@"TEST" refreshToken:nil expiryDate:[NSDate dateWithTimeIntervalSinceNow:3600] userIdentifier:nil]*/;
|
/*[[KBAuthManager shared] saveAccessToken:@"TEST" refreshToken:nil expiryDate:[NSDate dateWithTimeIntervalSinceNow:3600] userIdentifier:nil]*/;
|
||||||
@@ -48,11 +73,39 @@
|
|||||||
UITabBarAppearance *a = [UITabBarAppearance new];
|
UITabBarAppearance *a = [UITabBarAppearance new];
|
||||||
[a configureWithOpaqueBackground];
|
[a configureWithOpaqueBackground];
|
||||||
a.backgroundColor = [UIColor whiteColor];
|
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.standardAppearance = a;
|
||||||
self.tabBar.scrollEdgeAppearance = 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
|
#pragma mark - Navigation
|
||||||
|
|
||||||
|
|||||||
@@ -76,6 +76,7 @@
|
|||||||
_tableView = [[BaseTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
_tableView = [[BaseTableView alloc] initWithFrame:CGRectZero style:UITableViewStylePlain];
|
||||||
_tableView.dataSource = self;
|
_tableView.dataSource = self;
|
||||||
_tableView.delegate = self;
|
_tableView.delegate = self;
|
||||||
|
_tableView.bounces = false;
|
||||||
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone; // 设计为卡片式,去掉系统分割线
|
_tableView.separatorStyle = UITableViewCellSeparatorStyleNone; // 设计为卡片式,去掉系统分割线
|
||||||
_tableView.showsVerticalScrollIndicator = NO;
|
_tableView.showsVerticalScrollIndicator = NO;
|
||||||
_tableView.contentInset = UIEdgeInsetsMake(8, 0, KB_SafeAreaBottom(), 0);
|
_tableView.contentInset = UIEdgeInsetsMake(8, 0, KB_SafeAreaBottom(), 0);
|
||||||
|
|||||||
Reference in New Issue
Block a user