Search code examples
iostitaniumappceleratorappcelerator-titaniumappcelerator-alloy

Change font colour of picker on iOS in Titanium


How can I change the text colour of a picker using Titanium on the iOS platform.

From the looks of it, I can only change the background colour, and I can only change the font colour on the Android platform.


Solution

  • When creating a PickerRow, you can set the color property:

    http://docs.appcelerator.com/platform/latest/#!/api/Titanium.UI.PickerRow-property-color

    If that doesn't work, then you can do same as the example which is in the link above (creating Labels and adding them to each PickerRow):

    var fruit = [ 'Bananas', 'Strawberries', 'Mangos', 'Grapes' ];
    
    var column1 = Ti.UI.createPickerColumn();
    
    for(var i=0, ilen=fruit.length; i<ilen; i++){
      var row = Ti.UI.createPickerRow();
    
      var label = Ti.UI.createLabel({
        color:'red',
        font:{fontSize:20,fontWeight:'bold'},
        text: fruit[i],
        textAlign:'left',
        width:'126'
      });
    
      row.add(label);
      column1.addRow(row);
    }