Ответ 1
Вам нужно создать фоновый вид и назначить его ячейке:
func setTableViewBackgroundGradient(sender: UITableViewController, _ topColor:UIColor, _ bottomColor:UIColor) {
let gradientBackgroundColors = [topColor.CGColor, bottomColor.CGColor]
let gradientLocations = [0.0,1.0]
let gradientLayer = CAGradientLayer()
gradientLayer.colors = gradientBackgroundColors
gradientLayer.locations = gradientLocations
gradientLayer.frame = sender.tableView.bounds
let backgroundView = UIView(frame: sender.tableView.bounds)
backgroundView.layer.insertSublayer(gradientLayer, atIndex: 0)
sender.tableView.backgroundView = backgroundView
}
Также не забудьте установить цвет фона UITableViewCell
для очистки цвета:
override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) {
cell.backgroundColor = UIColor.clearColor()
}