Skip to content

Instantly share code, notes, and snippets.

@yuanmai
Forked from anonymous/gist:4325856
Created December 18, 2012 07:42
Show Gist options
  • Save yuanmai/4325891 to your computer and use it in GitHub Desktop.
Save yuanmai/4325891 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];
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment