Class

ColorGroup


Description

The ColorGroup class allows you to do dynamic light/dark target color selection.

Properties

Name

Type

Read-Only

Shared

UndefinedColorCallback

UndefinedColorDelegate

Methods

Name

Parameters

Returns

Shared

AddColor

platform As ColorGroup, aColor As Color

AddColorPair

platform As ColorGroup, lightColor As Color, darkColor As Color

AddNamedColor

platform As ColorGroup, name As String

Constructor

defaultColor As Color

Constructor

defaultLightColor As Color, defaultDarkColor As Color

Constructor

name As String

Mode

platform As Platforms = Platforms.Current

Modes

Name

String

NamedColor

name As String

Color

Values

Color()

Delegate Methods

Name

Parameters

Returns

UndefinedColorDelegate

ByRef c As Color

Enumerations

ColorGroup.Modes

Modes

The mode for the color group (Single, Dual, Named).

Enum

Description

Single

A single color.

Dual

A dual color has separate colors for light and dark modes.

Named

Refers to an OS system color name.

None

No color is selected.

ColorGroup.Platforms

Platforms

The platform for the color group.

Enum

Description

Current

The current platform.

Default

The default platform.

Desktop

Desktop apps.

Mobile

Mobile (iOS) apps.

Web

Web apps.

Property descriptions


ColorGroup.UndefinedColorCallback

UndefinedColorCallback As UndefinedColorDelegate

Set a delegate here to have it be called if a specified named color is undefined.

Method descriptions


ColorGroup.AddColor

AddColor(platform As ColorGroup, aColor As Color)

Adds a single color to a color group.


ColorGroup.AddColorPair

AddColorPair(platform As ColorGroup, lightColor As Color, darkColor As Color)

Adds a dual color to a color group.


ColorGroup.AddNamedColor

AddNamedColor(platform As ColorGroup, name As String)

Adds a named color to a color group.

Note

On iOS if you provide a name for a color that is not supported on the device, the appropriate color as defined in iOS 13 will be returned.


ColorGroup.Constructor

Constructor(defaultColor As Color)

Note

Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.

Creates a single mode ColorGroup with the specified color.


ColorGroup.Constructor

Constructor(defaultLightColor as Color, defaultDarkColor as Color)

Note

Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.

Creates a dual mode ColorGroup with the specified light and dark colors.


ColorGroup.Constructor

Constructor(name as String)

Note

Constructors are special methods called when you create an object with the New keyword and pass in the parameters above.

Creates a named mode ColorGroup with the specified named color.

If you provide a name for a color that is not supported on the device, the appropriate color as defined in iOS 13 will be returned.


ColorGroup.Mode

Mode(platform As Platforms = Platforms.Current) As Modes

The mode for the color group.


ColorGroup.Name

Name As String

The name for the color group.


ColorGroup.NamedColor

NamedColor(name As String) As Color

Returns the specified named color.

This method is shared.

Raises these exceptions:

Apple provides documentation for named colors for MacOS.

Additionally primaryContentBackgroundColor and secondaryContentBackgroundColor are valid names specifically for the macOS alternating table row background colors.


ColorGroup.Values

Values As Color()

The color values for the current platform of the color group.

Delegate descriptions


ColorGroup.UndefinedColorDelegate

UndefinedColorDelegate(ByRef c As Color)

Specifies a delegate method that can be called when a named color is undefined.

Notes

Comparisons and conversions

A ColorGroup can be directly compared to a Color value to determine if they are the same. It's important to remember of course that you can comparing the known color to the color of the ColorGroup at that moment as a ColorGroup can return different colors based upon the state of the device.

If myColorGroup = Color.Blue Then
  Canvas1.DrawingColor = Color.Blue
Else
  Canvas1.DrawingColor = Color.Red
End If

When you assign a ColorGroup to a Color property or variable, the color you receive the is color at that moment. For example, in a ColorGroup set to dual color, if you ask for the color when the device is in dark mode, you'll get the dark color.

Assigning a color to a ColorGroup assigns it to the Light Color (the default).

You can assign a named color to a ColorGroup by setting the ColorGroup equal to the name:

myColorGroup = "Link"

For macOS and iOS, Apple provides a complete list of valid named colors. These colors will automatically switch between light and dark modes. Apple's Adaptable System Colors will also automatically switch between light and dark modes but the Fixed Colors will not.

When using a name from Apple's documentation, the case must match as well.

Compatibility

All project types on all supported operating systems.