Skip to content

Commit 995babb

Browse files
committed
add support for tint
1 parent f7b02bc commit 995babb

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

SIAlertView/SIAlertView.m

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,8 @@ + (void)initialize
202202

203203
UIFont *defaultButtonFont = [UIFont systemFontOfSize:[UIFont buttonFontSize]];
204204
UIFont *otherButtonFont = [UIFont boldSystemFontOfSize:[UIFont buttonFontSize]];
205-
appearance.defaultButtonAttributes = @{NSFontAttributeName : defaultButtonFont, NSForegroundColorAttributeName : [UIColor blackColor]};
206-
appearance.cancelButtonAttributes = @{NSFontAttributeName : otherButtonFont, NSForegroundColorAttributeName : [UIColor blackColor]};
205+
appearance.defaultButtonAttributes = @{NSFontAttributeName : defaultButtonFont};
206+
appearance.cancelButtonAttributes = @{NSFontAttributeName : otherButtonFont};
207207
appearance.destructiveButtonAttributes = @{NSFontAttributeName : otherButtonFont, NSForegroundColorAttributeName : [UIColor colorWithRed:0.96f green:0.37f blue:0.31f alpha:1.00f]};
208208
}
209209

@@ -1037,7 +1037,7 @@ - (UIButton *)buttonForItemIndex:(NSUInteger)index
10371037
[button setBackgroundImage:highlightedImage forState:UIControlStateHighlighted];
10381038
[button addTarget:self action:@selector(buttonAction:) forControlEvents:UIControlEventTouchUpInside];
10391039

1040-
NSAttributedString *title = item.attributedTitle ? item.attributedTitle : [[NSAttributedString alloc] initWithString:item.title attributes:defaults];
1040+
NSAttributedString *title = item.attributedTitle ? item.attributedTitle : [[NSAttributedString alloc] initWithString:item.title attributes:[self tintedAttributes:defaults]];
10411041
[button setAttributedTitle:title forState:UIControlStateNormal];
10421042

10431043
return button;
@@ -1103,6 +1103,16 @@ - (UIImage *)imageWithUIColor:(UIColor *)color
11031103
return image;
11041104
}
11051105

1106+
- (NSDictionary *)tintedAttributes:(NSDictionary *)attributes
1107+
{
1108+
if (!attributes[NSForegroundColorAttributeName]) {
1109+
NSMutableDictionary *temp = [attributes mutableCopy];
1110+
temp[NSForegroundColorAttributeName] = self.tintColor;
1111+
attributes = [temp copy];
1112+
}
1113+
return attributes;
1114+
}
1115+
11061116
#pragma mark - UIAppearance setters
11071117

11081118
- (void)setViewBackgroundColor:(UIColor *)viewBackgroundColor

0 commit comments

Comments
 (0)