'How to change background color cell.detailTextLabel starting iOS 14?

Since iOS 14, detailTextLabel is marked as deprecated (with API_TO_BE_DEPRECATED) and therefore it's recommended to avoid it.

Now I have the following code (simplified for the example)

- (void)tableView:(UITableView *)tableView willDisplayCell:(UITableViewCell *)cell forRowAtIndexPath:(NSIndexPath *)indexPath {
    
    // Code simplified for the example
    cell.detailTextLabel.backgroundColor = [UIColor redColor];
}

Can I somehow keep the logic of this code without creating a custom cell while avoiding access to detailTextLabel?

My objective is to show something like the following:

enter image description here



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source