# Attribute

An abstract datatype for specifying an attributed string attribute.

Availability
3.6.0
3.6.0
9.2.0
Extends
Object

NOTE

This is an abstract type. Any object of this structure can be used where this type is used.

# Overview

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.

# Properties

# range

Availability
3.6.0
3.6.0
9.2.0
range :Array<Number>

Attribute range.

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


# type

Availability
3.6.0
3.6.0
9.2.0
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

Availability
3.6.0
3.6.0
9.2.0
value :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 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 ATTRIBUTE_UNDERLINES_STYLE or 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 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 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 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 ATTRIBUTE_TEXT_EFFECT, you must use the ATTRIBUTE_LETTERPRESS_STYLE constant.

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

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