+MSHook(CGColorRef, UIKBGetNamedColor, CFStringRef colorName)
+{
+ static CFMutableDictionaryRef keyboardColors;
+ if (!keyboardColors) {
+ keyboardColors = CFDictionaryCreateMutable(kCFAllocatorDefault, 0, &kCFTypeDictionaryKeyCallBacks, &kCFTypeDictionaryValueCallBacks);
+ NSString *path = [[NSBundle bundleWithPath:@"/System/Library/Frameworks/UIKit.framework"] pathForResource:@"UIKBColors" ofType:@"plist"];
+ NSDictionary *colorSettings = [NSDictionary dictionaryWithContentsOfFile:path];
+ if (colorSettings) {
+ CGColorSpaceRef colorSpace = CGColorSpaceCreateDeviceRGB();
+ for (NSString *settingName in [colorSettings allKeys]) {
+ NSArray *c = [colorSettings objectForKey:settingName];
+ CGFloat components[4];
+ switch ([c count]) {
+ case 1:
+ components[0] = [[c objectAtIndex:0] floatValue];
+ components[1] = components[0];
+ components[2] = components[0];
+ components[3] = 1.0f;
+ break;
+ case 2:
+ components[0] = [[c objectAtIndex:0] floatValue];
+ components[1] = components[0];
+ components[2] = components[0];
+ components[0] = [[c objectAtIndex:1] floatValue];
+ break;
+ case 3:
+ components[0] = [[c objectAtIndex:0] floatValue];
+ components[1] = [[c objectAtIndex:1] floatValue];
+ components[2] = [[c objectAtIndex:2] floatValue];
+ components[3] = 1.0f;
+ break;
+ case 4:
+ components[0] = [[c objectAtIndex:0] floatValue];
+ components[1] = [[c objectAtIndex:1] floatValue];
+ components[2] = [[c objectAtIndex:2] floatValue];
+ components[3] = [[c objectAtIndex:3] floatValue];
+ break;
+ default:
+ continue;
+ }
+ CGColorRef color = CGColorCreate(colorSpace, components);
+ CFDictionarySetValue(keyboardColors, settingName, color);
+ CFRelease(color);
+ }
+ CGColorSpaceRelease(colorSpace);
+ }
+ }
+ return (CGColorRef)CFDictionaryGetValue(keyboardColors, colorName) ?: _UIKBGetNamedColor(colorName);
+}
+