icekomo
icekomo

Reputation: 9466

Change the color of a UITableView grouped cells border

I've tried just about everything, but nothing seems to be working. I am trying to change the color of border of either the uitableview or the uitableViewCell, I can't really tell which one it is. Here is image to show what I am talking about, it's the default grey border. Tought to see but it's about 1px on top and bottom, and then divider line between the cells.

enter image description here

Here is what I have tried:

tableView.backgroundColor = Styles.blackColor()
cell.layer.borderColor = UIColor.yellowColor().CGColor

The Styles is a class where I'm keeping all my visual settings, it's just returning UIColors.

Upvotes: 1

Views: 1002

Answers (2)

Nuno Vieira
Nuno Vieira

Reputation: 303

If you want to change the color:

tableView.separatorColor = UIColor.yellowColor()

If you want to simply remove it:

tableView.separatorStyle = .None

If you want to make the separator full width:

    cell.separatorInset = UIEdgeInsetsMake(0, 0, cell.frame.size.width, 0)
    if (cell.respondsToSelector("preservesSuperviewLayoutMargins")){
        cell.layoutMargins = UIEdgeInsetsZero
        cell.preservesSuperviewLayoutMargins = false
    }

Upvotes: 2

CloudTuan
CloudTuan

Reputation: 91

I think you want to change the color of separator of table view.

tableView.separatorColor = [UIColor redColor];

Upvotes: 3

Related Questions