Share via


UIView.GetAppearance 方法

定义

重载

GetAppearance(UITraitCollection)

返回指定 traits的外观代理。

GetAppearance(UITraitCollection, Type[])

返回指定 traits的外观代理。

GetAppearance<T>()

获取 UIView 子类的外观代理 UIView.UIViewAppearance

GetAppearance<T>(UITraitCollection)

获取 UIView 子类的外观代理 UIView.UIViewAppearance

GetAppearance<T>(UITraitCollection, Type[])

当视图托管在指定的层次结构中时,获取具有指定特征集合的 UIView 子类的外观代理 UIView.UIViewAppearance

GetAppearance(UITraitCollection)

返回指定 traits的外观代理。

public static UIKit.UIView.UIViewAppearance GetAppearance (UIKit.UITraitCollection traits);
static member GetAppearance : UIKit.UITraitCollection -> UIKit.UIView.UIViewAppearance

参数

返回

适用于

GetAppearance(UITraitCollection, Type[])

返回指定 traits的外观代理。

public static UIKit.UIView.UIViewAppearance GetAppearance (UIKit.UITraitCollection traits, params Type[] containers);
static member GetAppearance : UIKit.UITraitCollection * Type[] -> UIKit.UIView.UIViewAppearance

参数

containers
Type[]

返回

适用于

GetAppearance<T>()

获取 UIView 子类的外观代理 UIView.UIViewAppearance

public static UIKit.UIView.UIViewAppearance GetAppearance<T> () where T : UIKit.UIView;
static member GetAppearance : unit -> UIKit.UIView.UIViewAppearance (requires 'T :> UIKit.UIView)

类型参数

T

必须为其返回 UIAppearance 代理的类型。 这是 UIView 的子类。

返回

指定类型的外观代理对象。

注解

在返回的对象上设置任何外观属性将影响类型参数的所有类和子类的外观。

Appearance与 属性或AppearanceWhenContainedIn(Type[])方法(仅适用于此特定类的实例)不同,GetAppearance 返回的代理可用于更改子类的样式。

以下示例演示 GetAppearance 方法的工作原理

var myTheme = UIView.GetAppearance<MyUIViewSubclass> ();
myTheme.TintColor = UIColor.Red;

有关详细信息,请参阅 UIAppearance 类的文档。

适用于

GetAppearance<T>(UITraitCollection)

获取 UIView 子类的外观代理 UIView.UIViewAppearance

public static UIKit.UIView.UIViewAppearance GetAppearance<T> (UIKit.UITraitCollection traits) where T : UIKit.UIView;
static member GetAppearance : UIKit.UITraitCollection -> UIKit.UIView.UIViewAppearance (requires 'T :> UIKit.UIView)

类型参数

T

必须为其返回 UIAppearance 代理的类型。 这是 UIView 的子类。

参数

traits
UITraitCollection

要匹配的特征集合。

返回

指定类型的外观代理对象。

注解

返回的对象表示 UIAppearance 代理,开发人员可在其中设置 UIView 实例的外观属性。

Appearance与 属性或AppearanceWhenContainedIn(Type[])方法(仅适用于此特定类的实例)不同,GetAppearance 返回的代理可用于更改子类的样式。

以下示例演示 GetAppearance 方法的工作原理

var myTheme = UIView.GetAppearance<MyUIViewSubclass> (myTraits, );
myTheme.TintColor = UIColor.Red;

有关详细信息,请参阅 UIAppearance 类的文档。

适用于

GetAppearance<T>(UITraitCollection, Type[])

当视图托管在指定的层次结构中时,获取具有指定特征集合的 UIView 子类的外观代理 UIView.UIViewAppearance

public static UIKit.UIView.UIViewAppearance GetAppearance<T> (UIKit.UITraitCollection traits, params Type[] containers) where T : UIKit.UIView;
static member GetAppearance : UIKit.UITraitCollection * Type[] -> UIKit.UIView.UIViewAppearance (requires 'T :> UIKit.UIView)

类型参数

T

必须为其返回 UIAppearance 代理的类型。 这是 UIView 的子类。

参数

traits
UITraitCollection

要匹配的特征集合。

containers
Type[]

开发人员希望用作应用此特定外观的容器的类型列表。

返回

指定类型的外观代理对象。

注解

返回的对象表示 UIAppearance 代理,当视图托管在指定层次结构中时,当这些实例包含在 参数指定的层次结构中时,开发人员可以在该代理中设置具有指定特征集合的 UIView 实例的外观 containers 属性。

Appearance与 属性或AppearanceWhenContainedIn(Type[])方法(仅适用于此特定类的实例)不同,GetAppearance 返回的代理可用于更改子类的样式。

以下示例演示 GetAppearance 方法的工作原理

var myTheme = UIView.GetAppearance<MyUIViewSubclass> (myTraits, typeof (UINavigationBar), typeof (UIPopoverController));
myTheme.TintColor = UIColor.Red;

有关详细信息,请参阅 UIAppearance 类的文档。

适用于