iOS button color?

I see that backgroundSelected color is only for Android.

How can I change button color (not background)?
And it would be even better if it could automatically add that iOS specific line across button like a mirror.

2 Answers

  • Accepted Answer

    I have been experimenting with setBackgroundGradient property and seems to work fine for gradients. I imagine that you can have a solid color backgroundGradient to give you the effect of one color change on click.

    var pictureButton = Titanium.UI.createButton({
                color: '#000',
                borderRadius: 10,
                borderColor: '#888',
                style: Titanium.UI.iPhone.SystemButtonStyle.PLAIN,
                backgroundGradient: { type:'linear', colors: [{color:'#f1f1f1', position:0.0}, {color:'#d3d3d3',position:1.0}] }
            pictureButton.addEventListener('touchstart', function() {
                pictureButton.setBackgroundGradient({type:'linear', colors: [{color:'#282828', position:0.0}, {color:'#d3d3d3',position:1.0}]});
            pictureButton.addEventListener('touchend', function() {
                pictureButton.setBackgroundGradient({type:'linear', colors: [{color:'#f1f1f1', position:0.0}, {color:'#d3d3d3',position:1.0}]});
    — answered 4 years ago by Javier Vega
    1 Comment
    • Thx for this. I decided to work with gradients also but I set it aside for know. Your code will speed up my researching process.

      — commented 4 years ago by Dino Bartosak
  • hi Dino,

    you can do one thing create one image with your backgroundSelected and set this as a property of backgroundSelectedImage. It may help you

    good luck

    — answered 4 years ago by Mitul Bhalia
    • actually you should create two image one with selectedColor and other with without selectedColor

      — commented 4 years ago by Mitul Bhalia
    • But that way if I decide to change my app color, I must create whole new images. Isn't there some better solution. Strange how iOS not supports this. (Or it is a Titanium thing)

      — commented 4 years ago by Dino Bartosak
    • yes you must create two images for that because i also tested with buttonBar and tabbedBar but no success

      — commented 4 years ago by Mitul Bhalia