Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[Catalyst] Provides access to macOS Accent Color
@implementation UIColor (AppleAccentColor)
+(UIColor *)CATALYSTAccentColor
{
BOOL hasAccentSet = ([[NSUserDefaults standardUserDefaults] objectForKey:@"AppleAccentColor"] != nil);
NSInteger systemAccentColor = [[NSUserDefaults standardUserDefaults] integerForKey:@"AppleAccentColor"];
UIColor *returnColor = [UIColor systemBlueColor];
if (hasAccentSet)
{
switch (systemAccentColor)
{
case -1:
returnColor = [UIColor systemGrayColor];
break;
case 0:
returnColor = [UIColor systemRedColor];
break;
case 1:
returnColor = [UIColor systemOrangeColor];
break;
case 2:
returnColor = [UIColor systemYellowColor];
break;
case 3:
returnColor = [UIColor systemGreenColor];
break;
case 5:
returnColor = [UIColor systemPurpleColor];
break;
case 6:
returnColor = [UIColor systemPinkColor];
break;
default:
break;
}
}
return returnColor;
}
@end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.