Created
November 26, 2013 15:06
-
-
Save rblalock/7659908 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var attr = Ti.UI.iOS.createAttributedString({ | |
text: text, | |
attributes: [ | |
// Underlines text | |
{ | |
type: Ti.UI.iOS.ATTRIBUTE_UNDERLINES_TYLE, | |
value: Ti.UI.iOS.ATTRIBUTE_UNDERLINE_STYLE_SINGLE | Ti.UI.iOS.ATTRIBUTE_UNDERLINE_PATTERN_DASH_DOT_DOT, | |
range: [0, text.length] | |
}, | |
// Sets a background color | |
{ | |
type: Ti.UI.iOS.ATTRIBUTE_BACKGROUND_COLOR, | |
value: "blue", | |
range: [text.indexOf('Titanium'), ('Titanium').length] | |
}, | |
// Sets a foreground color | |
{ | |
type: Ti.UI.iOS.ATTRIBUTE_FOREGROUND_COLOR, | |
value: "white", | |
range: [0, text.length] | |
}, | |
// Sets a background color | |
{ | |
type: Ti.UI.iOS.ATTRIBUTE_BACKGROUND_COLOR, | |
value: "yellow", | |
range: [text.indexOf('rocks!'), ('rocks!').length] | |
}, | |
// Sets a foreground color | |
{ | |
type: Ti.UI.iOS.ATTRIBUTE_FOREGROUND_COLOR, | |
value: "black", | |
range: [text.indexOf('rocks!'), ('rocks!').length] | |
}, | |
// Crossed out text | |
{ | |
type: Ti.UI.iOS.ATTRIBUTE_STRIKETHROUGH_STYLE, | |
value: Ti.UI.iOS.ATTRIBUTE_UNDERLINE_STYLE_SINGLE, | |
range: [text.indexOf('sucks'), ('sucks').length] | |
}, | |
// Creates a shadow | |
{ | |
type: Ti.UI.iOS.ATTRIBUTE_SHADOW, | |
value: { | |
offset: { | |
width: 1, | |
height: 1 | |
}, | |
blurRadius: 1, | |
color: 'green' | |
}, | |
range: [text.indexOf('Appcelerator'), ('Appcelerator').length] | |
} | |
/* | |
// Writing direction | |
// Only works in iOS7 and above - does not have side effects on iOS 6 | |
{ | |
type: Ti.UI.iOS.ATTRIBUTE_WRITING_DIRECTION, | |
value: Ti.UI.iOS.ATTRIBUTE_WRITING_DIRECTION_RIGHT_TO_LEFT | Ti.UI.iOS.ATTRIBUTE_WRITING_DIRECTION_OVERRIDE, | |
range: [0, text.length] | |
} | |
*/ | |
] | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment