1
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user