共用方式為


UIColor 建構函式

定義

多載

UIColor(CGColor)

從指定的 UIColor 建立新 CGColor

UIColor(CIColor)

從指定的 UIColor 建立新 CIColor

UIColor(NSCoder)

從儲存在 unarchiver 物件中的資料初始化 物件的建構函式。

UIColor(NSObjectFlag)

呼叫衍生類別的建構函式,以略過初始化,並只配置 物件。

UIColor(IntPtr)

建立 Unmanaged 物件的 Managed 標記法時所使用的建構函式;由執行時間呼叫。

UIColor(UIImage)

建立新的「色彩」,以提供圖樣影像填滿其區域。

UIColor(nfloat, nfloat)

使用 中的 white 灰階值和 中的 alpha 不透明度值,建立新的色彩。

UIColor(nfloat, nfloat, nfloat, nfloat)

來自紅色、綠色、藍色和 Alpha 元件的 UIColor 建構函式。

UIColor(CGColor)

從指定的 UIColor 建立新 CGColor

[Foundation.Export("initWithCGColor:")]
public UIColor (CoreGraphics.CGColor color);
new UIKit.UIColor : CoreGraphics.CGColor -> UIKit.UIColor

參數

color
CGColor
屬性

備註

這可從背景執行緒使用。

適用於

UIColor(CIColor)

從指定的 UIColor 建立新 CIColor

[Foundation.Export("initWithCIColor:")]
[ObjCRuntime.Unavailable(ObjCRuntime.PlatformName.WatchOS, ObjCRuntime.PlatformArchitecture.All, null)]
public UIColor (CoreImage.CIColor ciColor);
new UIKit.UIColor : CoreImage.CIColor -> UIKit.UIColor

參數

ciColor
CIColor
屬性

備註

這可從背景執行緒使用。

適用於

UIColor(NSCoder)

從儲存在 unarchiver 物件中的資料初始化 物件的建構函式。

[Foundation.Export("initWithCoder:")]
[ObjCRuntime.DesignatedInitializer]
public UIColor (Foundation.NSCoder coder);
new UIKit.UIColor : Foundation.NSCoder -> UIKit.UIColor

參數

coder
NSCoder

unarchiver 物件。

屬性

備註

提供這個建構函式,以允許在 NIB 還原序列化) 期間,從 unarchiver (初始化 類別。 這是通訊協定的 NSCoding 一部分。

如果開發人員想要建立這個物件的子類別,並繼續支援從封存還原序列化,他們應該實作具有相同簽章的建構函式:採用類型的 NSCoder 單一參數,並使用 [Export (「initWithCoder:」] 屬性宣告加以裝飾。

您也可以使用隨附方法 EncodeTo 序列化這個物件的狀態。

適用於

UIColor(NSObjectFlag)

呼叫衍生類別的建構函式,以略過初始化,並只配置 物件。

protected UIColor (Foundation.NSObjectFlag t);
new UIKit.UIColor : Foundation.NSObjectFlag -> UIKit.UIColor

參數

t
NSObjectFlag

未使用的 sentinel 值,傳遞 NSObjectFlag.Empty。

備註

當衍生類別在 Managed 程式碼中完全建構物件時,應該呼叫這個建構函式,並只想要讓執行時間配置和初始化 NSObject。 這是實作 Objective-C 所使用的雙步驟初始化程式的必要條件,第一個步驟是執行物件配置,第二個步驟是初始化物件。 當開發人員叫用採用 NSObjectFlag.Empty 的建構函式時,它們會利用直接路徑,而直接路徑會移至 NSObject,只設定物件的記憶體,並將 Objective-C 和 C# 物件系結在一起。 物件的實際初始化會由開發人員決定。

系結產生器通常會使用此建構函式來設定物件,但會防止實際初始化發生。 配置完成之後,建構函式必須初始化 物件。 使用系結產生器所產生的建構函式,這表示它會手動叫用其中一個 「init」 方法來初始化 物件。

如果開發人員使用 NSObjectFlag.Empty 路徑鏈結物件,開發人員必須負責完全初始化物件。

一般而言,如果開發人員的建構函式叫用 NSObjectFlag.Empty 基底實作,則它應該呼叫 Objective-C init 方法。 如果這不是這種情況,開發人員應該改為將其類別中的適當建構函式鏈結在一起。

忽略引數值,而且只會確保唯一執行的程式碼是建構階段是基本的 NSObject 配置和執行時間類型註冊。 通常鏈結看起來會像這樣:

//
// The NSObjectFlag merely allocates the object and registers the
// C# class with the Objective-C runtime if necessary, but no actual
// initXxx method is invoked, that is done later in the constructor
//
// This is taken from Xamarin.iOS's source code:
//
[Export ("initWithFrame:")]
public UIView (System.Drawing.RectangleF frame) : base (NSObjectFlag.Empty)
{
// Invoke the init method now.
	var initWithFrame = new Selector ("initWithFrame:").Handle;
	if (IsDirectBinding)
		Handle = ObjCRuntime.Messaging.IntPtr_objc_msgSend_CGRect (this.Handle, initWithFrame, frame);
	else
		Handle = ObjCRuntime.Messaging.IntPtr_objc_msgSendSuper_CGRect (this.SuperHandle, initWithFrame, frame);
}

適用於

UIColor(IntPtr)

建立 Unmanaged 物件的 Managed 標記法時所使用的建構函式;由執行時間呼叫。

protected internal UIColor (IntPtr handle);
new UIKit.UIColor : nativeint -> UIKit.UIColor

參數

handle
IntPtr

nativeint

指向 Unmanaged 物件的指標 (控制碼) 。

備註

執行時間基礎結構會叫用此建構函式 () GetNSObject(IntPtr) ,為 Unmanaged Objective-C 物件的指標建立新的 Managed 標記法。 開發人員不應該直接叫用此方法,而是應該呼叫 GetNSObject 方法,因為它會防止 Managed 物件的兩個實例指向相同的原生物件。

適用於

UIColor(UIImage)

建立新的「色彩」,以提供圖樣影像填滿其區域。

[Foundation.Export("initWithPatternImage:")]
public UIColor (UIKit.UIImage patternImage);
new UIKit.UIColor : UIKit.UIImage -> UIKit.UIColor

參數

patternImage
UIImage
屬性

備註

(此節點的更多檔即將推出)

這可從背景執行緒使用。

適用於

UIColor(nfloat, nfloat)

使用 中的 white 灰階值和 中的 alpha 不透明度值,建立新的色彩。

[Foundation.Export("initWithWhite:alpha:")]
public UIColor (nfloat white, nfloat alpha);
new UIKit.UIColor : nfloat * nfloat -> UIKit.UIColor

參數

white
nfloat
alpha
nfloat
屬性

備註

(此節點的更多檔即將推出)

這可從背景執行緒使用。

適用於

UIColor(nfloat, nfloat, nfloat, nfloat)

來自紅色、綠色、藍色和 Alpha 元件的 UIColor 建構函式。

[Foundation.Export("initWithRed:green:blue:alpha:")]
public UIColor (nfloat red, nfloat green, nfloat blue, nfloat alpha);
new UIKit.UIColor : nfloat * nfloat * nfloat * nfloat -> UIKit.UIColor

參數

red
nfloat

紅色元件,0.0 到 1.0f。

green
nfloat

綠色元件 0.0 到 1.0f。

blue
nfloat

藍色元件值 0.0 到 1.0f。

alpha
nfloat

Alpha (透明度) 0.0 到 1.0f 的值。

屬性

備註

這可從背景執行緒使用。

適用於