How to underline labels?
Hi All,
I was wondering what is the best way to underline a Label created by Titanium.UI.createLabel()
Thanks,
Ajay
4 Answers
-
AFAIK, underline is not a supported style for native iPhone labels so I'd guess, that there's no way in Titanium. Don't know for Android, though.
-
Worst case you can add a view with a height of 1 and the same width of the label placed directly under the label.
-
Hi,
you can easily wrap your label with a view which calculates the size of the label after a certain timeout and adds a line view.function decorateLabel(label) { var decoratedView = Titanium.UI.createView({ width : Titanium.UI.SIZE, height : Titanium.UI.SIZE, layout : 'vertical', left : 0 }); decoratedView.add(label); setTimeout(function() { var lineView = Titanium.UI.createView({ width : label.getSize().getWidth(), left : label.left, height : 1, backgroundColor : label.color ? label.color : 'white', top : -1, bottom : 0 }); decoratedView.add(lineView); }, 100); return decoratedView; }
-
On iOS Titanium label does not support underline style (TiLabel is basically wrapped around the UILabel but doesnt utilise the attributedText). We've created a replacement for UILabel that supports underline along with other few goodies - you can try it here.