I basically want the opacity of every layer in my UITableView instance to “fade out” at the top 10 or so pixels.
Is there any way to fade out a CALayer (or more generally, a UIView)’s opacity? It’d be similar in effect to adding a shadow with a CAGradientLayer but instead of covering the table view’s other layers with another, it would apply a filter to them to make them transparent according to a gradient.
Yes, by using the
CALayer‘smaskproperty, but it’s rather inefficient. Typically this sort of effect is done by overlaying a gradient that goes from transparent to the background color on top of your view (but this only works if you know what your background is).