Created
July 18, 2012 21:21
-
-
Save alanleard/3138983 to your computer and use it in GitHub Desktop.
Underline function
This file contains hidden or 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 win = Ti.UI.createWindow(); | |
win.open(); | |
function label(args){ | |
var view = Ti.UI.createView({ | |
width:'size', | |
height:'size', | |
layout:'vertical' | |
}); | |
var label = Ti.UI.createLabel({ | |
text:args.text, | |
color:args.color, | |
width:'size', | |
bottom:1 | |
}); | |
view.add(label); | |
if(args.underline){ | |
label.addEventListener('postlayout', function(){ | |
if(!view.children[1]){ | |
var underline = Ti.UI.createView({ | |
backgroundColor:args.color, | |
height:1, | |
width:label.size.width, | |
bottom:0 | |
}); | |
view.add(underline); | |
} | |
}); | |
} | |
return view; | |
} | |
win.add(label({text:'This is my test label', color:'white', underline:true})); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment