Fade UITableView’s Edges

I took this tutorial and made some changes and additions:

It now works on all tableviews – even if they are part of bigger screen.
It works regardless of the background or whatever is behind the tableview.
The mask changes depends on the position of the table view – when scrolled to top only the bottom faded, in when scrolled to bottom only top is faded…
1. Start by importing QuartzCore and setting a mask layer in your controller:

2. Add this to viewWillAppear:

3. Make sure you are a delegate of UIScrollViewDelegate by adding it in the .h of your controller:

4. To finish, implement scrollViewDidScroll: in your controller .m:

Again: most of the solution is from this tutorial in cocoanetics.