How to add a background image to a table view

The easiest way to do this is by adding a UIImage to your table. Rather than instantiating a new table object you can simply add the following line into the first Table View Data Source method you have – such as this one:

Just make sure you do this before the return statement (which ends the method, ignoring all code beyond).

Note that in grouped tables the cell object has its own background. You can set its colour in Interface Builder (use clearColour if you’d like your background to shine through) or you can use the tableView:cellForRowAtIndexPath method to override it separately with something else:

Again make sure you add this statement before the return cell call.

About Jay Versluis

Jay is a medical miracle known as Super Survivor. He runs two YouTube channels, five websites and several podcast feeds. To see what else he's up to, and to support him on his mission to make the world a better place, check out his Patreon Campaign.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.