1
This commit is contained in:
@@ -143,7 +143,7 @@ static const CGFloat JXheightForHeaderInSection = 50;
|
||||
|
||||
self.naviBGView = [[UIView alloc] init];
|
||||
self.naviBGView.alpha = 0;
|
||||
self.naviBGView.backgroundColor = [UIColor whiteColor];
|
||||
self.naviBGView.backgroundColor = [UIColor clearColor];
|
||||
self.naviBGView.frame = CGRectMake(0, 0, KB_SCREEN_WIDTH, KB_NAV_TOTAL_HEIGHT);
|
||||
[self.view addSubview:self.naviBGView];
|
||||
UILabel *naviTitleLabel = [[UILabel alloc] init];
|
||||
@@ -219,15 +219,15 @@ static const CGFloat JXheightForHeaderInSection = 50;
|
||||
|
||||
|
||||
- (void)pagerView:(JXPagerView *)pagerView mainTableViewDidScroll:(UIScrollView *)scrollView {
|
||||
// 正确的吸顶阈值:头图高度 - 固定区偏移(即导航高度)
|
||||
// 计算吸顶阈值:头图高度 - 固定区偏移(即导航高度)
|
||||
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;
|
||||
// 分类条背景:未吸顶时透明,吸顶后白色
|
||||
// 触发吸顶的大致阈值 ≈ 头图高度 - 顶部偏移(此处用头图高度近似即可)
|
||||
|
||||
// 不要渐变:小于阈值 alpha=0,达到阈值(吸顶)后 alpha=1
|
||||
BOOL shouldWhite = (thresholdDistance > 0.0 && scrollView.contentOffset.y >= (thresholdDistance - 0.5));
|
||||
self.naviBGView.alpha = shouldWhite ? 1.0 : 0.0;
|
||||
|
||||
// 分类条背景:未吸顶时透明,吸顶后白色
|
||||
if (shouldWhite != self.categoryIsWhite) {
|
||||
self.categoryIsWhite = shouldWhite;
|
||||
UIColor *bg = shouldWhite ? [UIColor whiteColor] : [UIColor clearColor];
|
||||
|
||||
Reference in New Issue
Block a user