Search code examples
iosobjective-cuitableviewcustom-cellaccessoryview

Change background color of accessoryView in UITableViewCell


I have a custom cell (not using xib), and I'm trying to change the background color of the accessory view. Here is my code and what I tried"

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath
{
    customCell *cell = [tableView dequeueReusableCellWithIdentifier:@"cellID" forIndexPath:indexPath];

    cell.accessoryView.backgroundColor = [UIColor redColor];

    return cell;
}

Results:

The background color didn't change.


Solution

  • You can do this in either of two ways. You can change the table view's tint color, which will change the color of the accessory, or you can drag in any view or control you want, and change its color to whatever you want.