I've been searching for answers in Google. I found this, but it only tells me about the gradient "behind" the table view, and it's not scrollable. Also found this, but it's still static. My own solution was:
-(void)setupGradientBg{
//background gradient for channel page
CAGradientLayer *gLayer = [CAGradientLayer layer];
gLayer.colors = @[
(id)[UIColor whiteColor].CGColor,
(id)[UIColor blackColor].CGColor
];
gLayer.startPoint = CGPointMake(0, 0);
gLayer.endPoint = CGPointMake(1, -1);
CGRect frame = self.channelInfoTableView.bounds;
frame.origin.y = frame.origin.y - (self.channelInfoTableView.contentSize.height / 2);
frame.size.height = self.channelInfoTableView.contentSize.height + (self.channelInfoTableView.contentSize.height / 2);
gLayer.frame = frame;
[gLayer setMasksToBounds:YES];
[self.channelInfoTableView.layer insertSublayer:gLayer atIndex:0];
}
Then calling it inside cellForRowAtIndexPath when the row is the last index, but it seem to be repeating in each cell.
I also tried calling this method after reloading the table view, but it seem to be cut above (I assumed, the layer of the tableView might not have the same size as the tableView's contentSize)
If you noticed on my code, I deducted its y position in order to extend when the user scrolls up further, and I also increased the height if in case the user scrolls down too much.
I just wanted for the gradient layer to be "the same size as the table view's content size" so that if I scroll down in the table view, the gradient background follows. Can anyone please help me with this problem? I will appreciate it, thank you!