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.

  • 3.6.0
  • 3.6.0
  • 3.6.0

NOTE This is an abstract type. Any object meeting this description can be used where this type is used.

Defined By

Properties

Attribute
range : Number[]

Attribute range.

Attribute range.

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

Attribute
value : Number

Attribute value.

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_TEXT_EFFECT, you must use the only supported iOS 7 constant Titanium.UI.ATTRIBUTE_LETTERPRESS_STYLE.

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.

This API can be assigned the following constants: