GitHub - hexperimental/HxTwoStepButton: UIButton Subclass with a confirmation step before triggering the button's action · GitHub
Skip to content

hexperimental/HxTwoStepButton

Folders and files

Repository files navigation

HxTwoStepButton

UIButton subclass with a confirmation step before triggering the button's action

How to use

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];

Available settings

//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];

Delegate

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...");
}

Contact

HxTwoStepButton is available under the MIT license. See the LICENSE file for more info.

About

UIButton Subclass with a confirmation step before triggering the button's action

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

Contributors