initWithColors:atLocations:colorSpace:
指定したカラーの配列と位置の配列でグラデーションオブジェクトを初期化して返します
-(id)initWithColors:(NSArray *)colorArray: atLocations:(CGFloat *)locations: colorSpace:(NSColorSpace *)colorSpace:
解説
指定したカラーの配列と位置の配列でグラデーションオブジェクトを初期化して返します。
返り値
( id )
グラデーションオブジェクト(NSGradient)
引数
( NSArray * )colorArray
カラーの配列
( CGFloat * )locations
カラーの配列に対応する位置の配列(それぞれ0.0から1.0の範囲内)
( NSColorSpace * )colorSpace
カラースペース
フレームワーク
ApplicationKit
クラス
NSGradient
使用可能
10.5
参照
例文
#import "MyObject.h" @implementation MyObject - (IBAction)myAction:(id)sender { CGFloat colorLocations[3]; colorLocations[0]= 0.0; colorLocations[1]= 0.3; colorLocations[2]= 1.0; NSGradient *gradient = [[NSGradient alloc] initWithColors: [NSArray arrayWithObjects: [NSColor redColor], [NSColor blueColor], [NSColor greenColor], nil ] atLocations: colorLocations colorSpace: [NSColorSpace deviceRGBColorSpace] ]; [theView lockFocus]; [gradient drawInRect: NSMakeRect(0,0,100,100) angle:(CGFloat)[theSlider floatValue]]; [theView unlockFocus]; } @end