silyevsk's example is excellent... but, six months later, iOS 8 has come along, and it doesn't quite work properly anymore.
Now, you need to look for a subview called "_UITableViewCellActionButton
" and set the background color of that.
Below is a modified version of silyevsk's code which I've used in my app.
On some of my UITableView
cells, I didn't want the user to be able to swipe-to-delete, but I did want something (a padlock icon) to appear when they swiped.

To do this, I added a bReadOnly
variable to my UITableViewCell class
@interface NoteTableViewCell : UITableViewCell
. . .
@property (nonatomic) bool bReadOnly;
-(void)overrideConfirmationButtonColor;
@end
and I added silyevsk's code to my .m file:
- (UIView*)recursivelyFindConfirmationButtonInView:(UIView*)view
{
for(UIView *subview in view.subviews) {
if([NSStringFromClass([subview class]) rangeOfString:@"UITableViewCellActionButton"].location != NSNotFound)
return subview;
UIView *recursiveResult = [self recursivelyFindConfirmationButtonInView:subview];
if(recursiveResult)
return recursiveResult;
}
return nil;
}
-(void)overrideConfirmationButtonColor
{
if (!bReadOnly)
return;
dispatch_async(dispatch_get_main_queue(), ^{
UIView *confirmationButton = [self recursivelyFindConfirmationButtonInView:self];
if(confirmationButton)
{
confirmationButton.backgroundColor = [UIColor lightGrayColor];
UIImageView* imgPadLock = [[UIImageView alloc] initWithFrame:confirmationButton.frame];
imgPadLock.image = [UIImage imageNamed:@"icnPadlockBlack.png"];
imgPadLock.contentMode = UIViewContentModeCenter; // Don't stretch the UIImage in our UIImageView
// Add this new UIImageView in the UIView which contains our Delete button
UIView* parent = [confirmationButton superview];
[parent addSubview:imgPadLock];
}
});
}
Also, I needed to change the code which populates the UITableView
, otherwise the "Delete" label would appear aswell as the padlock icon:
-(NSString*)tableView:(UITableView *)tableView titleForDeleteConfirmationButtonForRowAtIndexPath:(NSIndexPath *)indexPath
{
Note* note = [listOfNotes objectAtIndex:indexPath.row];
if ( /* Is the user is allowed to delete this cell..? */ )
return @"Delete";
return @" ";
}
It's still ugly, and relies on assumptions that this won't all change when iOS 9 comes along.