Browse Source

Fix macOS accent color not respecting the current theme (#22143)

pull/22151/head
Julien Lebosquain 2 weeks ago
committed by GitHub
parent
commit
380bd8a2f4
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 15
      native/Avalonia.Native/src/OSX/PlatformSettings.mm

15
native/Avalonia.Native/src/OSX/PlatformSettings.mm

@ -45,9 +45,20 @@ public:
{
@autoreleasepool
{
if (@available(macOS 10.14, *))
if (@available(macOS 11.0, *))
{
__block NSColor* color;
[[NSApp effectiveAppearance] performAsCurrentDrawingAppearance:^{
color = [[NSColor controlAccentColor] colorUsingColorSpace:NSColorSpace.sRGBColorSpace];
}];
return to_argb(color);
}
else if (@available(macOS 10.14, *))
{
auto color = [NSColor controlAccentColor];
auto previousAppearance = NSAppearance.currentAppearance;
NSAppearance.currentAppearance = [NSApp effectiveAppearance];
auto color = [[NSColor controlAccentColor] colorUsingColorSpace:NSColorSpace.sRGBColorSpace];
NSAppearance.currentAppearance = previousAppearance;
return to_argb(color);
}
else

Loading…
Cancel
Save