This is the code, where I add the sublayer
func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) {
let layer = CAGradientLayer()
layer.frame = CGRect(x: 0, y: 0, width: 5000, height: 70)
layer.colors = [UIColor(red: 0.19, green: 0.22, blue: 0.25, alpha: 1.00).cgColor, UIColor(red: 0.25, green: 0.26, blue: 0.28, alpha: 1.00).cgColor]
cell.layer.addSublayer(layer)
}
This is the code, where I add the entrie/text Label, the filtered part I need for the search
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) - UITableViewCell {
let cell = tableView.dequeueReusableCell(withIdentifier: "cell", for: indexPath)
if filtered {
cell.textLabel?.text = filteredData[indexPath.row]
}
else{
cell.textLabel?.text = collectionEintraege[indexPath.row]
}
cell.layer.borderWidth = 1
cell.layer.borderColor = UIColor.white.cgColor
cell.textLabel?.textColor = UIColor.white
cell.textLabel?.font = UIFont(name: "Helvetica", size: 25.0)
return cell
}