Created
September 10, 2014 19:38
-
-
Save alanleard/61031aa6ba2aff8e26c5 to your computer and use it in GitHub Desktop.
Underline example
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 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