Created
December 26, 2020 17:54
-
-
Save kssreeram/4df35007b185a3e9fce37b04e9afc4bc to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#import <AppKit/AppKit.h> | |
int main() { | |
while (1) { | |
NSColor *color1 = [NSColor textColor]; | |
NSColor *color2 = [color1 colorUsingColorSpace:[NSColorSpace deviceRGBColorSpace]]; | |
CGFloat r, g, b, a; | |
[color2 getRed:&r green:&g blue:&b alpha:&a]; | |
printf("text-color: (%f, %f, %f, %f)\n", r, g, b, a); | |
[NSThread sleepForTimeInterval:1.0]; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Compile with
clang text-color.m -framework AppKit
.When the program starts, it displays the correct RGB values for the system text color. But if the system appearance is switched (say from light to dark) while the program is running, the printed value doesn't change accordingly.
How do I fix this?