macOS/iOS API解説

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

目次

alphaComponent

カラーのアルファ(不透明度)値を返します

解説

カラーのアルファ(不透明度)値を返します。
カラーがアルファを持たなければ1.0を返します。

返り値

( CGFloat )

不透明度0.0-1.0

引数

フレームワーク

ApplicationKit

クラス

NSColor

Instance Methods

使用可能

10.0

参照

例文

#import "Controller.h"

@implementation Controller

- (IBAction)myAction:(id)sender
{
	NSColor *theColor = [NSColor colorWithDeviceRed:1 green:0.3 blue:0.8 alpha:1];
		
	[name setStringValue:@"r1:g0.3:b0.8:alpha1"];
	[name setTextColor:theColor];
	[r setFloatValue:[theColor redComponent]];
	[g setFloatValue:[theColor greenComponent]];
	[b setFloatValue:[theColor blueComponent]];
	[alpha setFloatValue:[theColor alphaComponent]];
}

@end