Image for post
Image for post
Photo by Alice Achterhof on Unsplash

Taking classes in Titanium Alloy to the next level

Rene Pot
Rene Pot
Aug 20, 2018 · 3 min read
myUIElement.backgroundColor = "#ffffff";
<Label class="myLabel" />
'.myLabel': {
font: {
fontSize: 14
},
color: 'red'
}

Dynamic Styling

<Alloy autoStyle="true">
<Label autoStyle="true" />
"global": {
"autoStyle": true
}

Using Alloy classes methods

$.myLabel.color = "#666666";
$.myLabel.font = { fontStyle: 'italic', fontWeight: 'normal' };
'.enabled': {
color: '#000000',
font: {
fontStyle: 'normal',
fontWeight: 'bold'
}
}
'.disabled': {
color: '#666666',
font: {
fontStyle: 'italic',
fontWeight: 'normal'
}
}
$.removeClass($.myLabel, 'enabled');
$.addClass($.myLabel, 'disabled');
$.resetClass($.myLabel, 'disabled');
$.resetClass($.myLabel, 'disabled largeLabel');

Dynamic styling based on conditions

".DynamicLabel[if=Alloy.Globals.isPortrait]": {}
".DynamicLabel[if=Alloy.Globals.isLandscape]": {}
$.resetClass($.DynamicLabel, 'DynamicLabel');

Conclusion

All Titanium

Everything about App Development using Appcelerator…

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch
Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore
Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store