macOS/iOS API解説

iOS , Mac アプリケーション開発のために使われる主要フレームワークの日本語情報です。2010年代に書かれた内容です。今後更新はありません。

目次

CGColorRelease

INDEX>CoreGraphics>CGColor

__
void CGColorRelease (
   CGColorRef color
);

解説

カラーを破棄します。

返り値

引数

CGColorRef

参照

- (void)drawRect:(CGRect)rect {

	#ifdef TARGET_OS_IPHONE
		// iPhone SDK の API を使用して CGContextRef を取得する
		CGContextRef context = UIGraphicsGetCurrentContext();
		//アンチエイリアス
		//CGContextSetAllowsAntialiasing(context, false);
	#else
		CGContextRef	context = [[NSGraphicsContext currentContext] graphicsPort];
	#endif
	
	//コンテキストに線のカラーをセットします。
    float col[4];
    col[0] = 1.0;
    col[1] = 1.0;
    col[2] = 0.5;
    col[3] = 0.5;
    CGColorSpaceRef space = CGColorSpaceCreateDeviceRGB();
    CGColorRef color = CGColorCreate(space,col);

    CGContextSetFillColorWithColor(context,color);
	//CGContextSetRGBFillColor(context, 0, 0, 0.5, 1);
	//弧の位置
	CGPoint				theLocation;//
	theLocation = CGPointMake(200.0, 200.0);
	//弧をパスに加える
	CGContextAddArc(context, theLocation.x, theLocation.y, 100, radians(0), radians(270), 0);
	
	CGContextFillPath(context);
    
    CGColorRelease(color);
}