Skip to content

Commit 603cbfc

Browse files
committed
fine tune highlight color calculation method
1 parent 995babb commit 603cbfc

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

SIAlertView/SIAlertView.m

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1082,13 +1082,19 @@ - (UIColor *)highlightedColorWithColor:(UIColor *)color
10821082
if (numComponents == 2) {
10831083
[color getWhite:&brightness alpha:&alpha];
10841084
brightness += brightness > 0.5 ? -adjustment : adjustment * 2; // emphasize lighten adjustment value by two
1085+
if (alpha < 0.5) {
1086+
alpha += adjustment;
1087+
}
10851088
return [UIColor colorWithWhite:brightness alpha:alpha];
10861089
}
10871090

10881091
// RGBA
10891092
[color getHue:&hue saturation:&saturation brightness:&brightness alpha:&alpha];
10901093
brightness += brightness > 0.5 ? -adjustment : adjustment * 2;
1091-
1094+
if (alpha < 0.5) {
1095+
alpha += adjustment;
1096+
}
1097+
10921098
return [UIColor colorWithHue:hue saturation:saturation brightness:brightness alpha:alpha];
10931099
}
10941100

0 commit comments

Comments
 (0)