Are NSColors available such as tungsten and steel?

I know that Cocoa gives you whiteColor, blackColor, darkGrayColorbut they also have the color Apple color panel? With colors like Snow, Tungsten, Steel, Tin? Or should I create them myself?

+3
source share
3 answers

You want an NSColorList . The one called "Crayons" corresponds to a pencil in the Color panel.

+6
source

rgb NSColor. NSColor rgb

+1

You can add to and make ANY color with ANY name you want ... Therefore, you need to make 2 files ... ... CategoriesNSColorNSColor+YourCategories.h

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

and aptly named NSColor+YourCategories.mfile

#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;
 }

Simply

#import NSColor+YourCategories.h

on any page you want to be able to link to your named colors, for example ...

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

∀Ⓛ∃✖

0
source

Source: https://habr.com/ru/post/1740817/


All Articles