I need to add an inner shadow effect to my UITableView. I’ve discovered this helpful post on adding an inner shadow to a UIView layer: Inner shadow effect on UIView layer?
The problem arises when I attempt to use this technique on a UITableView because the UITableView’s cells are displayed on top, covering the shadow.
I’ve played around with adding the UITableView as a subview to a UIView (with the inner shadow) to no effect.
My UITableView is centered on the UIViewController’s view with a dark gray background. Giving the UITableView an inner shadow would give the background the effect of being a bezel for the table view.
How would I best achieve the effect I’m looking for on a UITableView?
Answering my own question:
I ended up subclassing a UIView and implementing the drawRect function using this post: Inner shadow effect on UIView layer?
Then instructed the new UIView subclass to forward all touch events through to the underlying view controllers by implementing the following method:
Finally, I added the new view as a subview to my main view, set its background to be transparent, positioned it on top of the tableView and brought it to the front.