Skip to content

Commit 5af1bbb

Browse files
committed
Support for system colors using the NS prefix
1 parent 32cb7e4 commit 5af1bbb

File tree

1 file changed

+22
-0
lines changed

1 file changed

+22
-0
lines changed

ColorSetKit/NSColor+ColorSetKit.m

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,28 @@ + ( nullable NSColor * )colorFromColorSet: ( NSString * )name
5454

5555
[ Lock unlock ];
5656

57+
if( [ name hasPrefix: @"NS" ] )
58+
{
59+
{
60+
NSMutableString * selectorName;
61+
SEL sel;
62+
63+
selectorName = [ name substringFromIndex: 2 ].mutableCopy;
64+
65+
if( selectorName.length > 0 )
66+
{
67+
[ selectorName replaceCharactersInRange: NSMakeRange( 0, 1 ) withString: [ selectorName substringToIndex: 1 ].lowercaseString ];
68+
69+
sel = NSSelectorFromString( selectorName );
70+
71+
if( sel && [ NSColor respondsToSelector: sel ] )
72+
{
73+
return [ NSColor performSelector: sel ];
74+
}
75+
}
76+
}
77+
}
78+
5779
{
5880
ColorPair * pair;
5981

0 commit comments

Comments
 (0)