Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@tw93
Last active March 21, 2018 11:16
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tw93/cd9d847b16854af13e49d996dc853a05 to your computer and use it in GitHub Desktop.
Save tw93/cd9d847b16854af13e49d996dc853a05 to your computer and use it in GitHub Desktop.
[weex] Support setting color about <switch>

Background

  • Currently, the 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 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.
iOSWeb

How to Use

<switch on-tint-color="#C33D3E" 
        thumb-tint-color="#FF7703" 
        tint-color="#850B0B" 
        checked="true"></switch>

My solution

Code

Details

iOS

It can be overwritten with the onTintColorthumbTintColortintColor attributes of switchView, as well as the job of updating the attributes.

...
_switchView.onTintColor = _onTintColor;
_switchView.thumbTintColor = _thumbTintColor;
_switchView.tintColor = _tintColor;

Web

Override the corresponding CSS styles.

Welcome to put forward any suggestion about the solution or other requirements for the component, Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment