This commit is contained in:
2025-11-13 15:34:56 +08:00
parent debbe2777b
commit f406416698
9 changed files with 263 additions and 19 deletions

View File

@@ -18,7 +18,7 @@
- (void)viewDidLoad {
[super viewDidLoad];
self.view.backgroundColor = [UIColor whiteColor];
self.view.backgroundColor = [UIColor clearColor];
// collectionView
[self.view addSubview:self.collectionView];
@@ -133,7 +133,7 @@
UICollectionViewFlowLayout *layout = [UICollectionViewFlowLayout new];
layout.scrollDirection = UICollectionViewScrollDirectionVertical;
_collectionView = [[UICollectionView alloc] initWithFrame:CGRectZero collectionViewLayout:layout];
_collectionView.backgroundColor = [UIColor whiteColor];
_collectionView.backgroundColor = [UIColor clearColor];
_collectionView.dataSource = self;
_collectionView.delegate = self;
// cell

View File

@@ -13,6 +13,9 @@
#import <JXPagingView/JXPagerView.h>
#import <MJRefresh/MJRefresh.h>
#import "KBShopItemVC.h"
#import "KBSearchVC.h"
#import "MySkinVC.h"
#import "KBWebViewViewController.h"
@@ -31,6 +34,10 @@ static const CGFloat JXheightForHeaderInSection = 50;
@property (nonatomic, strong) JXCategoryTitleView *categoryView;
@property (nonatomic, strong) NSArray <NSString *> *titles;
@property (nonatomic, strong) UIImageView *bgImageView; //
@property (nonatomic, strong) UIButton *searchBtn;
@property (nonatomic, strong) UIButton *skinBtn;
//
@property (nonatomic, assign) BOOL categoryIsWhite;
@end
@@ -45,6 +52,18 @@ static const CGFloat JXheightForHeaderInSection = 50;
make.edges.equalTo(self.view);
}];
[self setupUI];
[self.view addSubview:self.skinBtn];
[self.view addSubview:self.searchBtn];
[self.skinBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.view).offset(-16);
make.top.mas_equalTo(KB_NAV_TOTAL_HEIGHT - 25);
make.width.height.mas_equalTo(25);
}];
[self.searchBtn mas_makeConstraints:^(MASConstraintMaker *make) {
make.right.equalTo(self.skinBtn.mas_left).offset(-16);
make.top.equalTo(self.skinBtn);
make.width.height.mas_equalTo(25);
}];
}
@@ -62,7 +81,7 @@ static const CGFloat JXheightForHeaderInSection = 50;
_userHeaderView = [[KBShopHeadView alloc] init];
_categoryView = (JXCategoryTitleView *)[[KBCategoryTitleView alloc] initWithFrame:CGRectMake(0, 0, [UIScreen mainScreen].bounds.size.width, JXheightForHeaderInSection)];
self.categoryView.titles = self.titles;
self.categoryView.backgroundColor = [UIColor whiteColor];
self.categoryView.backgroundColor = [UIColor clearColor];
self.categoryView.delegate = self;
self.categoryView.titleSelectedColor = [UIColor colorWithHex:0x1B1F1A];
self.categoryView.titleColor = [UIColor colorWithHex:0x9F9F9F];
@@ -102,7 +121,7 @@ static const CGFloat JXheightForHeaderInSection = 50;
[self.view addSubview:self.pagerView];
// self.pagerView.listContainerView.scrollView.scrollEnabled = false;
// self.pagerView.listContainerView.listCellBackgroundColor = [UIColor clearColor];
self.categoryView.listContainer = (id<JXCategoryViewListContainer>)self.pagerView.listContainerView;
//
@@ -200,10 +219,50 @@ static const CGFloat JXheightForHeaderInSection = 50;
- (void)pagerView:(JXPagerView *)pagerView mainTableViewDidScroll:(UIScrollView *)scrollView {
CGFloat thresholdDistance = JXTableHeaderViewHeight;
CGFloat percent = scrollView.contentOffset.y/thresholdDistance;
// -
CGFloat headerH = (CGFloat)[self tableHeaderViewHeightInPagerView:self.pagerView];
CGFloat thresholdDistance = MAX(0.0, headerH - self.pagerView.pinSectionHeaderVerticalOffset);
CGFloat percent = (thresholdDistance > 0 ? scrollView.contentOffset.y/thresholdDistance : 1);
percent = MAX(0, MIN(1, percent));
self.naviBGView.alpha = percent;
//
// -
BOOL shouldWhite = (thresholdDistance > 0.0 && scrollView.contentOffset.y >= (thresholdDistance - 0.5));
if (shouldWhite != self.categoryIsWhite) {
self.categoryIsWhite = shouldWhite;
UIColor *bg = shouldWhite ? [UIColor whiteColor] : [UIColor clearColor];
self.categoryView.backgroundColor = bg;
// collectionView
self.categoryView.collectionView.backgroundColor = bg;
}
}
#pragma mark - action
- (void)searchBtnAction{
KBSearchVC *vc = [[KBSearchVC alloc] init];
// [self.navigationController pushViewController:vc animated:true];
}
- (void)skinBtnAction{
MySkinVC *vc = [[MySkinVC alloc] init];
// [self.navigationController pushViewController:vc animated:true];
}
#pragma mark - lazy
- (UIButton *)searchBtn{
if (!_searchBtn) {
_searchBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_searchBtn setImage:[UIImage imageNamed:@"shop_search_icon"] forState:UIControlStateNormal];
[_searchBtn addTarget:self action:@selector(searchBtnAction) forControlEvents:UIControlEventTouchUpInside];
}
return _searchBtn;
}
- (UIButton *)skinBtn{
if (!_skinBtn) {
_skinBtn = [UIButton buttonWithType:UIButtonTypeCustom];
[_skinBtn setImage:[UIImage imageNamed:@"shop_skin_icon"] forState:UIControlStateNormal];
[_skinBtn addTarget:self action:@selector(skinBtnAction) forControlEvents:UIControlEventTouchUpInside];
}
return _skinBtn;
}
@end