Last active
February 22, 2017 09:30
-
-
Save NarendraPunchh/d1aa6d00b5331c49093e5926ddb12b37 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 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; | |
} |
Author
NarendraPunchh
commented
Feb 3, 2017
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment