Skip to content

Commit 0960db2

Browse files
authored
fix default icon color in ios dark mode (#145)
1 parent 111a97e commit 0960db2

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

ios/ContextMenuView.m

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,10 +187,20 @@ - (UIMenuElement*) createMenuElementForAction:(ContextMenuAction *)action atInde
187187
UIImage *iconImage = nil;
188188

189189
if (action.icon != nil) {
190-
UIColor *iconColor = [UIColor blackColor];
190+
UIColor *iconColor;
191191

192192
if (action.iconColor != nil) {
193193
iconColor = action.iconColor;
194+
} else {
195+
// Default color depends on dark mode
196+
if (@available(iOS 13.0, *)) {
197+
UIUserInterfaceStyle currentStyle = [UITraitCollection currentTraitCollection].userInterfaceStyle;
198+
iconColor = (currentStyle == UIUserInterfaceStyleDark) ? [UIColor whiteColor] : [UIColor blackColor];
199+
}
200+
// Fallback for iOS < 13
201+
else {
202+
iconColor = [UIColor blackColor];
203+
}
194204
}
195205
// Use custom icon from Assets.xcassets
196206
iconImage = [[UIImage imageNamed:action.icon] imageWithTintColor:iconColor];

0 commit comments

Comments
 (0)