I wanted to change the color of minus button and delete button of UITableViewCell when click on edit button or swiping UITableView rows. I have imp
fist time you call willTransitionToState in .m (customcell)
- (void)willTransitionToState:(UITableViewCellStateMask)state{
NSLog(@"EventTableCell willTransitionToState");
[super willTransitionToState:state];
[self overrideConfirmationButtonColor];
}
Check version iOS, it's here, i'm using iOS 7 - iOS8
//at least iOS 8 code here
- (UIView*)recursivelyFindConfirmationButtonInView:(UIView*)view
{
if (floor(NSFoundationVersionNumber) > NSFoundationVersionNumber_iOS_7_1) {
// iOS 8+ code here
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;
}
}
else{
// Pre iOS 8 code here
for(UIView *subview in view.subviews) {
if([NSStringFromClass([subview class]) isEqualToString:@"UITableViewCellDeleteConfirmationButton"]) return subview;
UIView *recursiveResult = [self recursivelyFindConfirmationButtonInView:subview];
if(recursiveResult) return recursiveResult;
}
}
return nil;
}
-(void)overrideConfirmationButtonColor
{
dispatch_async(dispatch_get_main_queue(), ^{
UIView *confirmationButton = [self recursivelyFindConfirmationButtonInView:self];
if(confirmationButton)
{
UIColor *color = UIColorFromRGB(0xFF7373);
confirmationButton.backgroundColor = color;
}
});
}