So this is the way I approached using @Vijay_07's answer:
- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
// Fades out top and bottom cells in table view as they leave the screen
NSArray *visibleCells = [self.tableView visibleCells];
CGPoint offset = self.tableView.contentOffset;
CGRect bounds = self.tableView.bounds;
CGSize size = self.tableView.contentSize;
UIEdgeInsets inset = self.tableView.contentInset;
float y = offset.y + bounds.size.height - inset.bottom;
float h = size.height;
if (y > h) {
self.tableView.alpha = 1 - (y/h - 1)*4;
for (UITableViewCell *cell in visibleCells) {
cell.contentView.alpha = 1 - (y/h - 1)*4;
}
} else {
for (UITableViewCell *cell in visibleCells) {
cell.contentView.alpha = 1;
}
self.tableView.alpha = 1;
}
}
Meanwhile:
1) in your storyboard make sure you use a UIImageView below the table
2) in the viewDidLoad do this:
UIImageView *myImage = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"SAMEIMAGE HERE!!.png"]];
[self.tableView setBackgroundView: myImage];
[self.tableView setBackgroundColor:[UIColor clearColor]];
[self scrollViewDidScroll:self.tableView];
3) in your .h add <UIScrollViewDelegate>
and you should be fine.
UIViewpropertyalpha? How about theUIScrollViewDelegateprotocol? - Carl Veazey