Created
December 18, 2012 07:32
-
-
Save anonymous/4325856 to your computer and use it in GitHub Desktop.
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
- (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