diff --git a/ColorPicker/AppController.m b/ColorPicker/AppController.m index cfad3a8..a3572be 100755 --- a/ColorPicker/AppController.m +++ b/ColorPicker/AppController.m @@ -170,6 +170,9 @@ - (void)copyColorToPasteboard:(NSColor *)color [pasteBoard setString:[color colorToCMYKRepresentation] forType:NSStringPboardType]; break; case kFormatRGB: + case kFormatUIColor: + [pasteBoard setString:[color colorToUIColorRepresentation] forType:NSStringPboardType]; + break; default: [pasteBoard setString:[color colorToRGBRepresentation] forType:NSStringPboardType]; break; diff --git a/ColorPicker/Constants.h b/ColorPicker/Constants.h index 7b240a8..7043dc9 100755 --- a/ColorPicker/Constants.h +++ b/ColorPicker/Constants.h @@ -13,7 +13,8 @@ typedef enum { kFormatHEX, kFormatHexWithoutHash, kFormatRGB, - kFormatCMYK + kFormatCMYK, + kFormatUIColor } kFormats; #define kNumberOfColorsHistory 5 diff --git a/ColorPicker/NSColorFormatter.h b/ColorPicker/NSColorFormatter.h index feafacb..cad5452 100644 --- a/ColorPicker/NSColorFormatter.h +++ b/ColorPicker/NSColorFormatter.h @@ -16,9 +16,12 @@ /* returns #ff0000 */ - (NSString*)colorToHEXRepresentation; -/* returns #ff0000 */ +/* returns ff0000 */ - (NSString*)colorToHEXWithoutHashRepresentation; +/* returns [UIColor colorWithRed:1.0 green:1.0 blue:1.0 alpha:1.0] */ +- (NSString*)colorToUIColorRepresentation; + /* returns 30° */ - (NSString*)colorToHueRepresentation; diff --git a/ColorPicker/NSColorFormatter.m b/ColorPicker/NSColorFormatter.m index 7f2d900..5fe379e 100644 --- a/ColorPicker/NSColorFormatter.m +++ b/ColorPicker/NSColorFormatter.m @@ -82,6 +82,17 @@ - (NSString*)colorToHEXWithoutHashRepresentation return hex; } + +- (NSString*)colorToUIColorRepresentation +{ + NSString *uiColor = [NSString stringWithFormat:@"[UIColor colorWithRed:%.2f green:%.2f blue:%.2f alpha:1.0];", + [self redComponent], + [self greenComponent], + [self blueComponent]]; + + return uiColor; +} + - (NSString*)colorToHueRepresentation { float h = [self hueComponent]; diff --git a/ColorPicker/PreferencesController.xib b/ColorPicker/PreferencesController.xib index e49a3a1..e728112 100644 --- a/ColorPicker/PreferencesController.xib +++ b/ColorPicker/PreferencesController.xib @@ -324,6 +324,16 @@ _popUpItemAction: + + + UIColor ([UIColor colorWithRed:1.0...) + + 2147483647 + + + _popUpItemAction: + + @@ -620,6 +630,7 @@ + @@ -674,6 +685,11 @@ + + 50 + + + @@ -710,12 +726,13 @@ com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin com.apple.InterfaceBuilder.CocoaPlugin + com.apple.InterfaceBuilder.CocoaPlugin - 49 + 50