Skip to content

Instantly share code, notes, and snippets.

@alanleard
Created July 18, 2012 21:21
Show Gist options
  • Save alanleard/3138983 to your computer and use it in GitHub Desktop.
Save alanleard/3138983 to your computer and use it in GitHub Desktop.
Underline function
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