Reputation: 1090
func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
if indexPath.row == 0 {
tableView.separatorColor = UIColor.clear
} else {
tableView.separatorColor = UIColor.blue
}
}
I have the above code to change the separator color for only first row. However, the whole section itself turns out with a clear color separator instead of blue. Could you please help me with this. Any help would be greatly appreciated. Thank you.
Upvotes: 0
Views: 2739
Reputation: 11839
Don't use tableview default seperator.
tableView.separatorColor = UIColor.clear
or
tableView.separatorStyle = .none
In UITableViewCell
add a UIView
of 1 px height, give that whatever color you want. If same UITableViewCell
is used for all the table rows, then might be you can use something like -
seperatorView.hidden = indexPath.row != 0
Upvotes: 4