GitHub user tw93 opened a pull request:

    https://github.com/apache/incubator-weex/pull/1076

    +[ios] switch supports setting color

    ## Background
    - Currently, the 
[<switch>](http://weex-project.io/cn/references/components/switch.html) 
component in Weex only support the default green color, But many times the 
business needs to set color for the theme tone of the product, So <switch> 
needs to support setting the color.
    
    
    ## New Support &&  Demo
    - tintColor: Background color when the switch is turned on.
    - onTintColor: Border color and background color on Android when the switch 
is turned off.
    - thumbTintColor: Color of the foreground switch grip.
    
    <table><tr><td><img 
src="https://gw.alipayobjects.com/zos/rmsportal/echgZhufHYAqYQSSSyKJ.gif"; 
width="240"></td><td><img 
src="https://gw.alipayobjects.com/zos/rmsportal/zlyOBlQnVbloIizCdWKU.gif"; 
width="240"></td></tr></table>
    
    ## How to Use
    
    ```
    <switch on-tint-color="#C33D3E" 
            thumb-tint-color="#FF7703" 
            tint-color="#850B0B" 
            checked="true"></switch>
    ```
    
    ## My solution
    #### Code
    * Weex iOS:
      * 
[WXSwitchComponent.m](https://github.com/tw93/incubator-weex/blob/ios-feature-switch/ios/sdk/WeexSDK/Sources/Component/WXSwitchComponent.m)
    * Weex Vue Demo:
      * 
[http://dotwe.org/vue/99a13cce5a429c7b9bce9bea24253935](http://dotwe.org/vue/99a13cce5a429c7b9bce9bea24253935)
      * [Demo Bundle 
JS](http://dotwe.org/raw/dist/99a13cce5a429c7b9bce9bea24253935.bundle.wx)
    
    #### Details
    
    It can be overwritten with the 
`onTintColor`、`thumbTintColor`、`tintColor` attributes of `switchView`, as 
well as the job of updating the attributes.
    
    ```
    ...
    _switchView.onTintColor = _onTintColor;
    _switchView.thumbTintColor = _thumbTintColor;
    _switchView.tintColor = _tintColor;
    ```
    
    
    Welcome to put forward any suggestion about the solution or other 
requirements for the <switch> component, Thanks!

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/tw93/incubator-weex ios-feature-switch

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/incubator-weex/pull/1076.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #1076
    
----
commit 96c102effcb9955726c38c99371961288af6ea18
Author: Tw93 <tw93@...>
Date:   2018-03-20T07:23:09Z

    +[ios] switch supports setting color

----


---

Reply via email to