Is there a reason for the UITableViewCell.AccessoryType.disclosureIndicator inability to set the tintColor?

Define the cell's accessory colors is possible:

func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell
{
  guard let cell = tableView.dequeueReusableCell(withIdentifier: "myCell", for: indexPath) as? MyCell
  else {fatalError("Could not dequeue a cell")}
// cell.accessoryType = UITableViewCell.AccessoryType.disclosureIndicator   // >
  cell.accessoryType = UITableViewCell.AccessoryType.detailDisclosureButton // (i) >
// cell.accessoryType = UITableViewCell.AccessoryType.checkmark             // v
// cell.accessoryType = UITableViewCell.AccessoryType.detailButton          // (i)
  cell.backgroundColor = .green
  cell.tintColor = .red
}

But in any case the chevron only remain gray.

Is it a bug or there is a reason for that?

Accepted Reply

I could not find a good reason for it ; notably because you can set the color of the ℹ button, why not the disclosure ? In addition, if background cell is gray, it would be quite invisible ; so that really seems to be a missing feature (not to say a bug).


Once again, if you create an image, make it template, otrherwise it is really painfull to create an image for each color !

Replies

From what I read, it is not possible, unless you create an image for the chevron and set to right color !

h ttps://medium.com/@ronm333/changing-the-color-of-a-disclosure-indicator-666a7fdd9286


Note: may be you could create this image and store in xcassets as a template, so that you can set its color later


I've tried also all variations I could imagine

        cell.accessoryView?.tintColor = .red
        cell.accessoryView?.backgroundColor = .red
        cell.accessoryView?.layer.backgroundColor = UIColor.red.cgColor
        cell.accessoryView?.layer.borderColor = UIColor.red.cgColor
        cell.accessoryView?.layer.shadowColor = UIColor.red.cgColor


No result.


At last, could file a bug report, for improvement.

Thank you Claude for your answer and your tests.

I saw same suggestions, which are years old. Because of the time passed I'm surprise that the problem is till there. Before filling a bug report I'm trying to understand if there is a reason for which Apple didn't modified this behaviour.

I could not find a good reason for it ; notably because you can set the color of the ℹ button, why not the disclosure ? In addition, if background cell is gray, it would be quite invisible ; so that really seems to be a missing feature (not to say a bug).


Once again, if you create an image, make it template, otrherwise it is really painfull to create an image for each color !