Skip to content
Titanium SDK
Titanium Docs
Version13.4.1

Titanium.UI.Color

proxyAndroidiPhoneiPadmacOSsince 9.1.0

Extends Titanium.Proxy

Represents a color used for UI components.

This type may be used on iOS for assignment to any property typically taking a String color value. A developer is not expected to typically interact with a Titanium.UI.Color object, as we generate them under the hood when converting the passed in String representations. One major exception is use of the Titanium.UI.fetchSemanticColor method, which will return an instance to be passed to UI components. This instance will automatically "adapt" the receiver to light/dark mode changes.

The only current instance you'd receive this type on Android is through the Titanium.UI.Android.getColorResource method. Note that Android does not currently support passing in instances of this type for UI components/properties! You must convert to a hex string representation to pass this in to any color properties on Android.

See UI Element Colors and Standard Colors for lists of named colors to pass to Titanium.UI.fetchSemanticColor on iOS.

See R.color for a list of system color names to use to pass to Titanium.UI.Android.getColorResource on Android.

Properties 3

apiName

Stringsince Android 3.2.0, iPhone 3.2.0, iPad 3.2.0, macOS 9.2.0read-only

Inherited from Titanium.Proxy

The name of the API that this proxy corresponds to.

bubbleParent

Booleansince Android 3.0.0, iPhone 3.0.0, iPad 3.0.0, macOS 9.2.0

Inherited from Titanium.Proxy

Indicates if the proxy will bubble an event to its parent.

Default: true

Methods 5

Inherited from Titanium.Proxy

Adds the specified callback as an event listener for the named event.

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to invoke when the event is fired.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.

Inherited from Titanium.Proxy

Fires a synthesized event to any registered listeners.

Parameters
ParametersTypeDescription
nameString

Name of the event.

event?Dictionary

A dictionary of keys and values to add to the Titanium.Event object sent to the listeners.

Inherited from Titanium.Proxy

Removes the specified callback as an event listener for the named event.

Parameters
ParametersTypeDescription
nameString

Name of the event.

callbackCallback<Titanium.Event>

Callback function to remove. Must be the same function passed to addEventListener.

4 fields
bubbles Boolean

True if the event will try to bubble up if possible.

cancelBubble Boolean

Set to true to stop the event from bubbling.

source Object

Source object that fired the event.

type String

Name of the event fired.

Returns a hex string representation of the color (in the RRGGBB or AARRGGBB formats)

The returned value is an uppercase hex representation of the color with a leading '#'. If fully opaque, the alpha hex values will be omitted. For example, black would return '#000000'. Black with a 50% opacity would return '#80000000'

Returns String