Titanium JIRA Archive
Appcelerator Community (AC)

[AC-4564] Ability to assign class to a view element

GitHub Issuen/a
TypeImprovement
Priorityn/a
StatusResolved
ResolutionInvalid
Resolution Date2016-10-18T09:34:43.000+0000
Affected Version/sn/a
Fix Version/sn/a
ComponentsAlloy, Titanium SDK & CLI
Labelsn/a
ReporterILAY SENER
AssigneeShak Hossain
Created2016-10-18T00:23:53.000+0000
Updated2016-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' });

Comments

  1. Hans Knöchel 2016-10-18

    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!

JSON Source