Skip to content

Instantly share code, notes, and snippets.

@alanleard
Created September 10, 2014 19:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alanleard/61031aa6ba2aff8e26c5 to your computer and use it in GitHub Desktop.
Save alanleard/61031aa6ba2aff8e26c5 to your computer and use it in GitHub Desktop.
Underline example
var text = "Have you tried <u>hyperloop</u> yet?";
if(OS_IOS){
var iOSText = text.replace(/<u>|<\/u>/g,"");
var attr = Ti.UI.iOS.createAttributedString({
text: iOSText,
attributes: [
{
type: Ti.UI.iOS.ATTRIBUTE_UNDERLINES_STYLE,
value: Titanium.UI.iOS.ATTRIBUTE_UNDERLINE_STYLE_SINGLE,
range: [iOSText.indexOf('hyperloop'), ('hyperloop').length]
}
]
});
}
var label = Ti.UI.createLabel({
top:100,
width:Ti.UI.SIZE,
attributedString:OS_IOS?attr:null,
html:OS_IOS?null:text
});
$.index.add(label);
$.index.open();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment