1.3.7 • Published 6 years ago

toggle-switch-rn v1.3.7

Weekly downloads
114
License
MIT
Repository
github
Last release
6 years ago

Switch Component for react native, it works on iOS and Android.

github地址

  • 基于View样式改变实现switch功能

Installation

  • npm i toggle-switch-rn --save
  • import Switch from 'toggle-switch-rn'

Demo

<Switch
    isOn={this.state.resetSwitch * 1}
    animationType={0}
    change={() => {
        const resetSwitch = !(this.state.resetSwitch * 1)
        this.setState({ resetSwitch })
        this._changReset.call(this, resetSwitch)
    }}
/>

API

属性值作用是否装配备注
isOn开关状态
change开关改变后的方法
animationType开关动画效果默认0:spring
boxStyle容器样式
boxIsOnStyle开启时容器的样式
switchStyle按钮的样式
  • 属性默认值:
//动画效果类型
const animationType = [
    LayoutAnimation.spring,
    LayoutAnimation.linear,
    LayoutAnimation.easeInEaseOut
]

//默认样式
boxStyle:{
    width: 55,
    height: 30,
    borderRadius: 30,
    backgroundColor: '#D9D9D9'
},
boxIsOnStyle:{
    backgroundColor: '#1678FF'
},
switchStyle:{
    width: 30,
    height: 30,
    backgroundColor: '#fff',
    borderRadius: 30,
    borderColor: 'rgba(0,0,0,.1)',
    borderWidth: .5
},
animationType:0

MIT Licensed

1.3.7

6 years ago

1.3.6

6 years ago

1.2.6

6 years ago

0.1.2

6 years ago

0.1.1

6 years ago

0.1.0

6 years ago