-
-
Save gauravds/a0e7989c8c3eeb72e2b161878501259e to your computer and use it in GitHub Desktop.
This will help us in creating a clear section header. As right now the simple solution is to use a solid color in place of clear background so the content is not visible behind header.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#define Header_height 30 | |
- (void)scrollViewDidScroll:(UIScrollView *)scrollView { | |
for (UITableViewCell *cell in self.tblRedeemables.visibleCells) { | |
CGFloat hiddenFrameHeight = scrollView.contentOffset.y + Header_height - cell.frame.origin.y; | |
if (hiddenFrameHeight >= 0 || hiddenFrameHeight <= cell.frame.size.height) { | |
[self maskCell:cell | |
fromTopWithMargin:hiddenFrameHeight]; | |
} | |
} | |
} | |
- (void)maskCell:(UITableViewCell *)cell fromTopWithMargin:(CGFloat)margin { | |
cell.layer.mask = [self visibilityMaskForCell:cell withLocation:margin/cell.frame.size.height]; | |
cell.layer.masksToBounds = YES; | |
} | |
- (CAGradientLayer *)visibilityMaskForCell:(UITableViewCell *)cell withLocation:(CGFloat)location { | |
CAGradientLayer *mask = [CAGradientLayer layer]; | |
mask.frame = cell.bounds; | |
mask.colors = [NSArray arrayWithObjects:(id)[[UIColor colorWithWhite:1 alpha:0] CGColor], (id)[[UIColor colorWithWhite:1 alpha:1] CGColor], nil]; | |
mask.locations = [NSArray arrayWithObjects:[NSNumber numberWithFloat:location], [NSNumber numberWithFloat:location], nil]; | |
return mask; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment