expressionappceleratortss

Appcelerator Alloy Expressions in TSS


How can I go about writing expression for font size, top, height, width... with TSS in appcelerator alloy project

'.myLabel': {
    backgroundColor: '#fff',
    height: Ti.Platform.displayCaps.platformHeight / 2,
    width: (Ti.Platform.displayCaps.platformWidth + 50) / 2
}

Solution

  • You can't do calculations like this in TSS. You would do that in your controller and assign the value to each element OR use a global variable in alloy.js where you do the calculation and assign that variable. Have a look at this blog post: https://www.tidev.io/2014/10/22/how-to-use-expressions-in-tss/