iOS Guides | Samples

UIKit.UISwitch Class

A UIControl that displays an on/off switch.

See Also: UISwitch

Syntax

[Foundation.Register("UISwitch", true)]
[ObjCRuntime.Unavailable(ObjCRuntime.PlatformName.TvOS, ObjCRuntime.PlatformArchitecture.All, null)]
public class UISwitch : UIControl, IDisposable

Related content

Requirements

Namespace: UIKit
Assembly: Xamarin.iOS (in Xamarin.iOS.dll)
Assembly Versions: 0.0.0.0

The members of UIKit.UISwitch are listed below.

See Also: UIControl

Public Constructors

Default constructor that initializes a new instance of this class with no parameters.
Initializes the UISwitch with the specified frame.
A constructor that initializes the object from the data stored in the unarchiver object.

Protected Constructors

Constructor to call on derived classes to skip initialization and merely allocate the object.
A constructor used when creating managed representations of unmanaged objects; Called by the runtime.

Public Properties

[read-only]
static
AppearanceUISwitch+UISwitchAppearance. Strongly-typed property that returns the UIAppearance class for this class.
[read-only]
override
ClassHandleIntPtr. The handle for this class.
OffImageUIImage. The image to be used to indicate Off.
OnBoolean. This property returns if the state of the switch is on or off.
OnImageUIImage. The UIImage representing the On state.
OnTintColorUIColor. The tint color to use when the switch is turned on.
ThumbTintColorUIColor. The color used to tint the thumb.

Public Methods

static
AppearanceWhenContainedIn(params Type[]) : UISwitch+UISwitchAppearance
Returns a strongly typed UIAppearance for instances of this class when the view is hosted in the specified hierarchy.
EncodeTo(NSCoder)
Encodes the state of the object on the provided encoder
static
GetAppearance(UITraitCollection) : UISwitch+UISwitchAppearance
Returns an appearance proxy for the specified traits.
static
GetAppearance(UITraitCollection, params Type[]) : UISwitch+UISwitchAppearance
Returns an appearance proxy for the specified traits when found in the containers containment hierarchy.
static
GetAppearance<T>() : UISwitch+UISwitchAppearance
Obtains the appearance proxy UISwitchAppearance for the subclass of UISwitch.
static
GetAppearance<T>(UITraitCollection) : UISwitch+UISwitchAppearance
Obtains the appearance proxy UISwitchAppearance for the subclass of UISwitch.
static
GetAppearance<T>(UITraitCollection, params Type[]) : UISwitch+UISwitchAppearance
Obtains the appearance proxy UISwitchAppearance for the subclass of UISwitch that has the specified trait collection when the view is hosted in the specified hierarchy.
SetState(Boolean, Boolean)
This method changes the state of the switch, and will animate the change if specified.