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
.
NOTE This is an abstract type. Any object meeting this description can be used where this type is used.
Attribute range.
Attribute range.
This specifies the range of text to apply the property to, as an array of two numbers: [from, length]
.
Attribute to apply to the text.
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.
This API can be assigned the following constants:
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: