Skip to content

Commit b87eb06

Browse files
committed
Improve pull request dogo#85
1 parent 51a36cd commit b87eb06

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

SCLAlertView/SCLButton.m

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -64,14 +64,18 @@ - (void)parseConfig:(NSDictionary *)buttonConfig
6464
{
6565
self.defaultBackgroundColor = buttonConfig[@"backgroundColor"];
6666
}
67-
if (buttonConfig[@"borderColor"])
67+
if (buttonConfig[@"textColor"])
68+
{
69+
[self setTitleColor:buttonConfig[@"textColor"] forState:UIControlStateNormal];
70+
}
71+
if ((buttonConfig[@"borderColor"]) && (buttonConfig[@"borderWidth"]))
6872
{
6973
self.layer.borderColor = ((UIColor*)buttonConfig[@"borderColor"]).CGColor;
70-
self.layer.borderWidth = self.layer.borderWidth ?: 2.0f;
74+
self.layer.borderWidth = [buttonConfig[@"borderWidth"] floatValue];
7175
}
72-
if (buttonConfig[@"textColor"])
76+
else if (buttonConfig[@"borderWidth"])
7377
{
74-
[self setTitleColor:buttonConfig[@"textColor"] forState:UIControlStateNormal];
78+
self.layer.borderWidth = [buttonConfig[@"borderWidth"] floatValue];
7579
}
7680
}
7781

SCLAlertViewExample/ViewController.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,14 +40,13 @@ - (IBAction)showSuccess:(id)sender
4040

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

43-
button.layer.borderWidth = 2.0f;
44-
4543
button.buttonFormatBlock = ^NSDictionary* (void)
4644
{
4745
NSMutableDictionary *buttonConfig = [[NSMutableDictionary alloc] init];
4846

4947
buttonConfig[@"backgroundColor"] = [UIColor whiteColor];
5048
buttonConfig[@"textColor"] = [UIColor blackColor];
49+
buttonConfig[@"borderWidth"] = [NSNumber numberWithFloat:2.0f];
5150
buttonConfig[@"borderColor"] = [UIColor greenColor];
5251

5352
return buttonConfig;
@@ -141,6 +140,7 @@ - (IBAction)showAdvanced:(id)sender
141140

142141
buttonConfig[@"backgroundColor"] = [UIColor greenColor];
143142
buttonConfig[@"borderColor"] = [UIColor blackColor];
143+
buttonConfig[@"borderWidth"] = @"1.0f";
144144
buttonConfig[@"textColor"] = [UIColor blackColor];
145145

146146
return buttonConfig;

0 commit comments

Comments
 (0)