You can use the headerView
and footerView
properties of the UITableView. These allow you to specify custom UIViews that will be placed before and after your content cells.
So, you should initialize a UIView with some dummy inner views with alternating colors. The height for this UIView should be equal to tableView.frame.size.height
. then just do:
tableView.headerView = headerViewWithFakeColors;
tableView.footerView = footerViewWithFakeColors;
Also, you will also need to change the contentInset
property so that these fake header&footer views are only visible when the user is bouncing (with contentInset you can control the point where the tableview starts bouncing)
tableView.contentInset = UIEdgeInsetsMake(headerViewWithFakeColors.frame.size.height, 0, -footerViewWithFakeColors.frame.size.height, 0);