dogo / SCLAlertView

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

Differentiate color of close/cancel button #228

Closed tropicdome closed 7 years ago

tropicdome commented 7 years ago

From a user experience point of view it would be great to be able to change the color of the different buttons, especially the close/cancel button. It can be unintuitive for a user if the close button is the same color as the other button(s).

dogo commented 7 years ago

hi @tropicdome , you can configure your button specs

simulator screen shot 9 nov 2016 11 20 28

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

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

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

        return buttonConfig;
    };
dogo commented 7 years ago

Another approach

simulator screen shot 9 nov 2016 11 26 35

    SCLAlertView *alert = [[SCLAlertView alloc] initWithNewWindow];

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

    __block SCLAlertView *blockAlert = alert;
    SCLButton *button = [alert addButton:@"Close" actionBlock:^(void) {
        [blockAlert hideView];
    }];

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

        buttonConfig[@"backgroundColor"] = [UIColor redColor];
        buttonConfig[@"textColor"] = [UIColor blackColor];

        return buttonConfig;
    };

    [alert showSuccess:kSuccessTitle subTitle:kSubtitle closeButtonTitle:nil duration:0.0f];
tropicdome commented 7 years ago

I will try that. Thank you