dogo / SCLAlertView

Beautiful animated Alert View. Written in Objective-C
MIT License
3.5k stars 534 forks source link

Support for horizontal button as in a UIAlertView #90

Closed kartikthapar closed 9 years ago

kartikthapar commented 9 years ago

Currently, the buttons are stacked vertically. Adding a button changes frame dimensions for the alert's window. In an alert, you would expect to have 2 buttons stacked horizontally. So if simply there is a view style that enables that option; it would be great. Thanks

dogo commented 9 years ago

Indeed currently it's not supported. A PR to add this feature would be much appreciated.

kartikthapar commented 9 years ago

I will try for a PR; but it will be quite minimalistic.

dogo commented 8 years ago

@kartikthapar feature added at 1.0.3 release

dogo commented 8 years ago

@ignasibm , horizontal eg

- (IBAction)showSuccessWithHorizontalButtons:(id)sender {
    SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindow];
    [alert setHorizontalButtons:YES];

    SCLButton *button = [alert addButton:@"First Button" target:self selector:@selector(firstButton)];

    button.buttonFormatBlock = ^NSDictionary* (void)
    {
        NSMutableDictionary *buttonConfig = [[NSMutableDictionary alloc] init];

        buttonConfig[@"backgroundColor"] = [UIColor whiteColor];
        buttonConfig[@"textColor"] = [UIColor blackColor];
        buttonConfig[@"borderWidth"] = @2.0f;
        buttonConfig[@"borderColor"] = [UIColor greenColor];

        return buttonConfig;
    };

    [alert addButton:@"Second Button" actionBlock:^(void) {
        NSLog(@"Second button tapped");
    }];  
    [alert showSuccess:kSuccessTitle subTitle:kSubtitle closeButtonTitle:kButtonTitle duration:0.0f];
}