Skip to content

Instantly share code, notes, and snippets.

Created December 18, 2012 07:32
Show Gist options
  • Save anonymous/4325856 to your computer and use it in GitHub Desktop.
Save anonymous/4325856 to your computer and use it in GitHub Desktop.
- (void)viewWillAppear:(BOOL)animated
{
[super viewWillAppear:animated];
if (!maskLayer)
{
maskLayer = [CAGradientLayer layer];
CGColorRef outerColor = [UIColor colorWithWhite:1.0 alpha:1.0].CGColor;
CGColorRef innerColor = [UIColor colorWithWhite:1.0 alpha:0.0].CGColor;
maskLayer.colors = [NSArray arrayWithObjects:(id)outerColor,
(id)innerColor, (id)innerColor, (id)outerColor, nil];
maskLayer.locations = [NSArray arrayWithObjects:[NSNumber numberWithFloat:0.0],
[NSNumber numberWithFloat:0.2],
[NSNumber numberWithFloat:0.8],
[NSNumber numberWithFloat:1.0], nil];
maskLayer.bounds = CGRectMake(0, 0,
self.tableView.frame.size.width,
self.tableView.frame.size.height);
maskLayer.anchorPoint = CGPointZero;
[self.view.layer addSublayer:maskLayer];
}
}
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
[CATransaction begin];
[CATransaction setDisableActions:YES];
maskLayer.position = CGPointMake(0, scrollView.contentOffset.y);
[CATransaction commit];
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment