Adding a new delete confirmation button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- (void)willTransitionToState:(UITableViewCellStateMask)state { | |
CGRect f; | |
if ((state & UITableViewCellStateShowingDeleteConfirmationMask) == UITableViewCellStateShowingDeleteConfirmationMask) { | |
if (!_deleteButton) { | |
_deleteButton = [MPButton buttonWithType:MPButtonTypeAlert withTitle:NSLocalizedString(@"Delete",@"Delete")]; | |
[[_deleteButton titleLabel] setFont:[[UIFont buttonFont] changeFontSizeBy:-2]]; | |
[_deleteButton addTarget:self action:@selector(delete:) forControlEvents:UIControlEventTouchUpInside]; | |
[self addSubview:_deleteButton]; | |
} | |
f = RBRectCenterPositionY([_deleteButton frame], CGRectGetHeight([self frame])); | |
f.origin.x = CGRectGetWidth([self frame]); | |
[_deleteButton setFrame:f]; | |
f.origin.x = CGRectGetMaxX([self frame]) - [UIScreen tableContentPadding] - f.size.width; | |
_isDeleting = NO; | |
} else { | |
[super willTransitionToState:state]; | |
if (_deleteButton) { | |
f = [_deleteButton frame]; | |
if (_isDeleting) { | |
alpha = 0.0f; | |
} else { | |
f.origin.x = CGRectGetWidth([self frame]); | |
} | |
} | |
} | |
if (_deleteButton) { | |
[UIView animateWithDuration:0.3f | |
animations:^{ | |
[_deleteButton setFrame:f]; | |
[_deleteButton setAlpha:alpha]; | |
}]; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment