[AC-4564] Ability to assign class to a view element
GitHub Issue | n/a |
---|---|
Type | Improvement |
Priority | n/a |
Status | Resolved |
Resolution | Invalid |
Resolution Date | 2016-10-18T09:34:43.000+0000 |
Affected Version/s | n/a |
Fix Version/s | n/a |
Components | Alloy, Titanium SDK & CLI |
Labels | n/a |
Reporter | ILAY SENER |
Assignee | Shak Hossain |
Created | 2016-10-18T00:23:53.000+0000 |
Updated | 2016-10-18T09:34:43.000+0000 |
Description
Currently, it is only possible to assign styling parameters to view elements, like width, height etc. However, it would be a lot easier if it was possible to assign CLASS parameter, which would reduce the amount of code in controllers.
Instead of
var label1 = Ti.UI.createLabel({
color: '#900',
font: { fontSize:48 },
shadowColor: '#aaa',
shadowOffset: {x:5, y:5},
shadowRadius: 3,
text: 'A simple label',
textAlign: Ti.UI.TEXT_ALIGNMENT_CENTER,
top: 30,
width: Ti.UI.SIZE, height: Ti.UI.SIZE
});
would be a lot easier to have the below:
var label1 = Ti.UI.createLabel({
class: 'myLabelClass'
});
Classes are an Alloy concept and can only used there. If you want to add / remove a class to an alloy view, please check [addClass()](http://docs.appcelerator.com/platform/latest/#!/api/Alloy.Controller-method-addClass) and [removeClass](http://docs.appcelerator.com/platform/latest/#!/api/Alloy.Controller-method-removeClass) in the Alloy reference. Thx!