ParallaxTableViewHeader
ParallaxTableViewHeader copied to clipboard
Extreme scrolling causes blur effect bug
Hey,
What a brilliant parallax effect! Excellent job. I was only wondering if there was a way to fix this error:
What it is:
What it should be:
This occurs in the following circumstances:
- Scroll up to cover the header and reveal bottom cells
- Scroll very vigorously in one movement down again to reveal the header
- No side expansion with bounce or anything happens, it just increases in height and stays blurred.
A thing I have noticed is that the less the kParallaxDeltaFactor, the less the bug. I have it set a 1.0f. (The nav bar has nothing to do with it).
Any help would be greatly appreciated.
Hi, I found a possible solution. I changed the layoutHeaderViewForScrollViewOffset method to:
- (void)layoutHeaderViewForScrollViewOffset:(CGPoint)offset
{
CGRect frame = self.imageScrollView.frame;
if (offset.y > 0)
{
frame.origin.y = MAX(offset.y *kParallaxDeltaFactor, 0);
self.imageScrollView.frame = frame;
self.bluredImageView.alpha = 1 / kDefaultHeaderFrame.size.height * offset.y * 2;
self.clipsToBounds = YES;
}
else
{
CGFloat delta = 0.0f;
CGRect rect = kDefaultHeaderFrame;
delta = fabs(MIN(0.0f, offset.y));
rect.origin.y -= delta;
rect.size.height += delta;
self.imageScrollView.frame = rect;
self.clipsToBounds = NO;
self.headerTitleLabel.alpha = 1 - (delta) * 1 / kMaxTitleAlphaOffset;
self.bluredImageView.alpha = 1 / kDefaultHeaderFrame.size.height * offset.y * 2; <-- ADD THIS LINE
}
}
As you see I added the alpha to be updated in the else statement, which seems to have solved the problem.
Thanks @aborren . I encountered the same problem. Your solution works. The code should be updated accordingly.