タングステンやスチールなどのNSColorsも利用できますか?
-
26-09-2019 - |
質問
ココアがあなたに与えてくれるのは知っています whiteColor
, blackColor
, darkGrayColor
, 、しかし、Appleのカラーパネルの色もあるのですか?「スノー」、「タングステン」、「スチール」、「ブリキ」などの色で?それとも自分で作成する必要がありますか?
他のヒント
これらの色の RGB 値を見つけて、独自の NSColor を作成する必要があります。rgb からの NSColor のドキュメント ここ
あなたはCategories
にのNSColor
ののを追加することができますし、あなたが作る2つのファイル... NSColor+YourCategories.h
...
#import <Cocoa/Cocoa.h>
@interface NSColor (YourCategories) // Tag in () is "yours" to name,
+ (NSColor *) MAUVE;
@end
と適切な名前NSColor+YourCategories.m
ファイル
#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;
}
単に
#import NSColor+YourCategories.h
[[self window]setBackGroundColor: [NSColor MAUVE]];
∀Ⓛ∃✖
所属していません StackOverflow