Skip to content

Commit 729261f

Browse files
committed
NSColor category
1 parent 509f1c2 commit 729261f

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

ColorSetKit/NSColor+ColorSetKit.m

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
#import "NSColor+ColorSetKit.h"
2626
#import "ColorSet.h"
2727
#import "ColorPair.h"
28+
#import <objc/runtime.h>
2829

2930
static ColorSet * MainColorSet = nil;
3031
static NSLock * Lock = nil;
@@ -34,18 +35,13 @@ @implementation NSColor( ColorSetKit )
3435
+ ( nullable NSColor * )colorFromColorSet: ( NSString * )name
3536
{
3637
static dispatch_once_t once;
37-
static BOOL ( ^ isDark )( void );
3838

3939
dispatch_once
4040
(
4141
&once,
4242
^( void )
4343
{
44-
Lock = [ NSLock new ];
45-
isDark = ^
46-
{
47-
return NO;
48-
};
44+
Lock = [ NSLock new ];
4945
}
5046
);
5147

@@ -63,13 +59,16 @@ + ( nullable NSColor * )colorFromColorSet: ( NSString * )name
6359

6460
pair = [ MainColorSet.colors objectForKey: name ];
6561

66-
if( pair != nil )
62+
if( @available( macOS 10.14, * ) )
6763
{
68-
return ( pair.variant != nil && isDark() ) ? pair.variant : pair.color;
64+
if( pair.variant != nil && [ [ NSAppearance currentAppearance ].name isEqualToString: NSAppearanceNameDarkAqua ] )
65+
{
66+
return pair.variant;
67+
}
6968
}
69+
70+
return pair.color;
7071
}
71-
72-
return nil;
7372
}
7473

7574
@end

0 commit comments

Comments
 (0)