Skip to content

Titanium.UI.Attribute

An abstract datatype for specifying an attributed string attribute.

Attributes are added to the Titanium.UI.AttributedString object to create styled text. The attribute is a JavaScript Object containing three properties: type, value and range.

Since: 3.6.0 · Platforms: iphone, ipad, android, macos

Properties #

range#

Type: Array<Number>

Attribute range.

This specifies the range of text to apply the property to, as an array of two numbers: [from, length].

type#

Type: Number

Attribute to apply to the text.

On Android, only the following constants are supported
Titanium.UI.ATTRIBUTE_FONT, Titanium.UI.ATTRIBUTE_FOREGROUND_COLOR,
Titanium.UI.ATTRIBUTE_BACKGROUND_COLOR, Titanium.UI.ATTRIBUTE_STRIKETHROUGH_STYLE,
Titanium.UI.ATTRIBUTE_UNDERLINES_STYLE, Titanium.UI.ATTRIBUTE_LINK,
Titanium.UI.ATTRIBUTE_UNDERLINE_COLOR

ON iOS, Titanium.UI.ATTRIBUTE_LINK only supported on Titanium.UI.TextArea, with
editable set to false and autoLink enabled.

value#

Type: String, Number, Titanium.UI.Color, Object, ParagraphAttribute

Attribute value.

The value parameter depends on the type parameter. For example, to
use the foreground color on the text you would use Titanium.UI.ATTRIBUTE_FOREGROUND_COLOR
for the type and a color value for the value:

{
    type: Titanium.UI.ATTRIBUTE_FOREGROUND_COLOR,
    value: '#DDD',
    range: [0, 100]
}

On iOS, if you use Titanium.UI.ATTRIBUTE_UNDERLINES_STYLE or Titanium.UI.ATTRIBUTE_STRIKETHROUGH_STYLE,
you must use one or more of these constants:

These can be combined:

{
    type: Titanium.UI.ATTRIBUTE_UNDERLINES_STYLE,
    value: Titanium.UI.ATTRIBUTE_UNDERLINE_STYLE_SINGLE | Titanium.UI.ATTRIBUTE_UNDERLINE_PATTERN_DASH,
    range: [0, 100]
}

On iOS, if you use the Titanium.UI.ATTRIBUTE_WRITING_DIRECTION, you must use one or more of
these constants:

These can also be combined the same way as the underline styles.

On iOS, if you use the Titanium.UI.ATTRIBUTE_SHADOW, the value must be a JavaScript object containing
any of the offset, blurRadius or color properties:

{
    offset: {
        width: 10,
        height: 10
    },
    blurRadius: 10,
    color: 'red'
}

On iOS, if you use the Titanium.UI.ATTRIBUTE_PARAGRAPH_STYLE, the value must be ParagraphAttribute.
E.g:

{
    minimumLineHeight: 10.0,
    tailIndent: 5,
    lineBreakMode: Titanium.UI.ATTRIBUTE_LINE_BREAK_BY_WORD_WRAPPING
}

On iOS, if you use the Titanium.UI.ATTRIBUTE_TEXT_EFFECT, you must use the Titanium.UI.ATTRIBUTE_LETTERPRESS_STYLE constant.

On iOS, if you use the Titanium.UI.ATTRIBUTE_LINE_BREAK, you must use one of
these constants:

These can also be combined the same way as the underline styles.

Titanium SDK Documentation