Titanium JIRA Archive
Titanium SDK/CLI (TIMOB)

[TIMOB-15436] iOS: Support onTintColor for Ti.UI.Switch

GitHub Issuen/a
TypeNew Feature
PriorityMedium
StatusClosed
ResolutionFixed
Resolution Date2014-04-08T20:35:58.000+0000
Affected Version/sn/a
Fix Version/s2014 Sprint 07, 2014 Sprint 07 SDK, Release 3.3.0
ComponentsiOS
Labelsmodule_slider, qe-closed-3.3.0, qe-testadded
ReporterJoseph Sachs
AssigneeVishal Duggal
Created2013-10-06T21:50:29.000+0000
Updated2014-04-24T06:57:04.000+0000

Description

I manually updated TiUiSwitch.m to have the ability to set the onTintColor of the Ti.UI.Switch component. A simple Modification:
-(void)setOnTintColor_:(id)color
{
 
    if ([color isKindOfClass:[UIColor class]])
    {
 
        [[self switchView] setOnTintColor:color ];
 
    }
    else
    {
        TiColor *ticolor = [TiUtils colorValue:color];
        [[self switchView] setOnTintColor: [ticolor _color ] ];
 
    }
}
and in Ti Code:
var aSwitch = Ti.UI.createSwitch({value:true, onTintColor:'#282828'});
and that should do it.

Comments

  1. Vincent 2013-10-09

    refers to http://developer.appcelerator.com/question/158104/tiuiswitch-ios7-color
  2. Vincent 2013-10-09

    at the same time, please consider adding the ThumbTintColor property for a more complete IOS 7 Look and Feel
       
       -(void) setThumbTintColor_:(id)color
       {
           
               
               if ([color isKindOfClass:[UIColor class]])
               {
                   
                   [[self switchView] setThumbTintColor:color ];
                   
               }
               else
               {
                   TiColor *ticolor = [TiUtils colorValue:color];
                   [[self switchView] setThumbTintColor: [ticolor _color ] ];
                   
               }
           
       }
       
       
  3. James Wise 2013-10-09

    Bump!
  4. Jörgen Buder 2013-10-29

    Hi Please add the tintColor as well, and when would we be able to see this released? We have a customer request for this at the moment. Thanks
  5. Ingo Muschenetz 2013-10-29

    Hi [~buder], this will likely make it into the next patch release after 3.2.0.
  6. Jörgen Buder 2013-10-29

    ok, thanks, so the "fix version" is a latest note then? ;) Hope to see it in 3.2.1 then . .
  7. Joseph Sachs 2013-10-29

    Hi Jörgen, You can implement it manually, as I've mentioned in the current SDK (If you're in a hurry): Go to this file: /Users//Library/Application Support/Titanium/mobilesdk/osx/3.1.3.GA/iphone/Classes/TiUiSwitch.m Then add the code above, Clean your project, then you'll have access to it in Titanium like so: Ti.UI.createSwitch({value:true, onTintColor:'#282828'});
  8. Jörgen Buder 2013-10-29

    already done, thanks. Was just trying to clarify expectations on my end.
  9. Chris Lawn 2013-11-09

    definitely something that would be nice to have added in properly. Thanks for the tip on modifying the switch component as well, much appreciated! :)
  10. Craig Jones 2013-12-12

    Love this! Thanks for the bodge while we wait for it to be implemented in the SDK.
  11. Vishal Duggal 2014-03-27

    Test Case
        var win = Ti.UI.createWindow({backgroundColor:'white'});
        
        var switch1 = Ti.UI.createSwitch({value:false, tintColor:'black', onTintColor:'blue', thumbTintColor:'red'});
        
        win.add(switch1);
        
        win.open();
        
  12. Vishal Duggal 2014-03-27

    Pull pending against master https://github.com/appcelerator/titanium_mobile/pull/5547
  13. Priya Agarwal 2014-04-24

    Verified the issue with environment: Appc-Studio:3.3.0.201404211130 sdk:3.3.0.v20140423155715 acs:1.0.14 alloy:1.4.0-dev npm:1.3.2 titanium:3.3.0-dev titanium-code-processor:1.1.1-beta1 xCODE:5.1.1 Device:Iphone5(7.1) onTintColor property working fine on ios. hence closing the issue.

JSON Source