문제

I know Cocoa gives you whiteColor, blackColor, darkGrayColor, but do they also have the colors from in Apple's color panel? With colors like "Snow", "Tungsten", "Steel", "Tin" ? Or should I create those myself?

도움이 되었습니까?

해결책

You want NSColorList. The one named “Crayons” corresponds to the crayon box in the Color Panel.

다른 팁

You should find the rgb values for those colors and make your own NSColor. Documentation for NSColor from rgb here

You can add Categories to NSColor and make ANY color with ANY name you want… So you need a make 2 files… NSColor+YourCategories.h

#import <Cocoa/Cocoa.h>
@interface NSColor (YourCategories)  // Tag in () is "yours" to name,
+ (NSColor *) MAUVE;
@end    

and an aptly named NSColor+YourCategories.m file

#import "NSColor+YourCategories.h"
@implementation NSColor (YourCategories)
+ (NSColor *) MAUVE { static NSColor*  MAUVE = nil;  if( MAUVE == nil )
              MAUVE = [NSColor colorWithDeviceRed:0.712 green:0.570 blue:0.570 alpha:1.000];r
       return MAUVE;
 }

The simply

#import NSColor+YourCategories.h

on any page which you want to be able to refer to your named colors, like…

[[self window]setBackGroundColor: [NSColor MAUVE]];

∀Ⓛ∃✖

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top