black
黒色のNSColorを返します
解説
黒色のNSColorを返します。
グレイスケール値が0.0、アルファ値が1.0のNSColorを返します。
返り値
( NSColor * )
カラー
引数
フレームワーク
ApplicationKit
クラス
NSColor
使用可能
10.0
参照
- blackComponent
編集時のバージョン
macOS 10.14.5
Swift4.2
例文
Swift4.2
class MyView005: NSView { override func draw(_ rect: CGRect) { // let rectColor = NSColor.black let path = NSBezierPath() path.move(to: CGPoint(x: 100, y: 100)) path.appendRect(NSMakeRect(0.0, 0.0, 1500.0, 900.0)) path.lineWidth = 5.0 // 線の太さ rectColor.setFill() // 色をセット path.fill() } }
#import "Controller.h" @implementation Controller - (IBAction)myAction:(id)sender { NSColor *theColor = [NSColor blackColor];//カラー作成 [name setStringValue:@"black"];//outlet nameに文字をセット [name setTextColor:theColor];//outlet name(text field)の文字色をtheColorにする [w setFloatValue:[theColor whiteComponent]];//outlet r(text field)にtheColorのred値をセット [alpha setFloatValue:[theColor alphaComponent]];//outlet b(text field)にtheColorのalpha値をセット } @end