UIButton subclass with a confirmation step before triggering the button's action
Include HxTwoStepButton .h and .m files into your project.
Assign "HxTwoStepButton" as custom class to your UIButton on IB or create it Programmatically.
HxTwoStepButton *tsButton = [[HxTwoStepButton alloc] initWithFrame:CGRectMake(10,200,100,30)];
[tsButton setTitle:@"Touch Me" forState:UIControlStateNormal];//Text to display after the first tap
[tsButton setConfirmationString:@"You Sure?"];
//Background color for confirmation step
[tsButton setConfirmationColor:[UIColor redColor]];
//Time to delay the confirmation step before going back to normal
[tsButton setDelay:5.0];
//Setting the delegate
[tsButton setDelegate:self];To tap into the extra step:
on the header file (.h)
@interface [YOURCLASS] : UIViewController <HxTwoStepButtonDelegate>on the implementation file (.m)
-(void)buttonDidEnterConfirmation:(id)sender{
NSLog(@"Waiting For confirmation...");
}
-(void)buttonDidCancelConfirmation:(id)sender{
NSLog(@"Confirmation cancelled...");
}
HxTwoStepButton is available under the MIT license. See the LICENSE file for more info.
