1.2.5 • Published 6 years ago

react-native-sf-button v1.2.5

Weekly downloads
28
License
ISC
Repository
github
Last release
6 years ago

react-native-sf-button

实现Button功能,可设置背景图片、颜色、或者图片+标题模式

安装

npm install react-native-sf-button

show

Props 公共属性

parametertyperequired  descriptiondefault
typenumberyes按钮类型null
isAnimatedboolno是否有点击缩放动画no
titlestringno标题null
titleColorstringno标题颜色black
titleFontSizenumberno标题字体大小16
titleAlignstringno标题对其方式'center'
titleFontWeightstringno标题字体宽度'normal'
titleFontFamilystringno标题字体null
titelMarginarray('左','上','右','下')no标题边距null
containerStyleobjectno按钮容器样式null
onPressfunc (tag)=>{}no按钮点击事件null
onPressInfunc (tag)=>{}no按钮按下事件null
onPressOutfunc (tag)=>{}no按钮抬起事件null

Props || type=0 颜色模式

parametertyperequired  descriptiondefault
defaultColorstringno默认背景颜色white
selectColorstringno选中背景颜色null

Props || type=1 图片模式

parametertyperequired  descriptiondefault
defaultImagenumberyes默认背景图片null
selectImagenumberno选中背景图片null

Props || type=2 图标+标题模式

parametertyperequired  descriptiondefault
defaultIconnumberyes默认图标null
selectIconnumberno选中图标null
iconRationumber(0-1)no图标占按钮null
iconWidthnumberno图标宽度(单一设置,高度自适应)null
iconHeightnumberno图标高度(单一设置,宽度自适应null
iconMarginarray('左','上','右','下')no图标边距null

例子

import SFButton from 'react-native-sf-button'
export default class App extends Component {
    render() {
        return (
            <View style={styles.container}>
                <SFButton
                    onPress={()=> {
                        alert('1')
                    }}
                    type={0}
                    defaultColor={'red'}
                    selectColor={'green'}
                    title={'颜色按钮'}
                    titleColor={'black'}
                    titleFontSize={16}
                    containerStyle={{
                        marginTop: 50,
                        width: 200,
                        height: 50,
                        borderWidth: 1,
                        borderColor: 'black',
                        borderRadius: 25,
                    }}
                />
                <SFButton
                    type={0}
                    defaultColor={'red'}
                    selectColor={'green'}
                    title={'颜色按钮点击缩放'}
                    isAnimated={true}
                    titleColor={'black'}
                    titleFontSize={16}
                    containerStyle={{
                        marginTop: 50,
                        width: 200,
                        height: 50,
                        borderWidth: 1,
                        borderColor: 'black',
                        borderRadius: 25,
                    }}
                />
                <SFButton
                    type={1}
                    defaultImage={require('./image/btn1.png')}
                    selectImage={require('./image/btn2.png')}
                    title={'图片按钮'}
                    titleColor={'black'}
                    titleFontSize={16}
                    containerStyle={{
                        marginTop: 50,
                        width: 200,
                        height: 50,
                    }}
                />

                <SFButton
                    type={2}
                    defaultIcon={require('./image/p1.png')}
                    selectIcon={require('./image/p2.png')}
                    iconWidth={30}
                    titelMargin={[5, 0, 0, 0]}
                    title={'图标+文字'}
                    titleColor={'black'}
                    titleFontSize={16}
                    containerStyle={{
                        marginTop: 50,
                        width: 200,
                        height: 50,
                        borderWidth: 2,
                        borderColor: 'gray',
                        borderRadius: 25,
                    }}
                />
                <SFButton
                    type={2}
                    defaultIcon={require('./image/p1.png')}
                    selectIcon={require('./image/p2.png')}
                    iconWidth={30}
                    iconRatio={0.3}
                    title={'图标+文字'}
                    titleColor={'black'}
                    titleFontSize={16}
                    containerStyle={{
                        marginTop: 50,
                        width: 200,
                        height: 50,
                        borderWidth: 2,
                        borderColor: 'gray',
                        borderRadius: 25,
                    }}
                />
                <SFButton
                    type={3}
                    containerStyle={{
                        marginTop: 50,
                        width: 200,
                        height: 50,
                        borderWidth: 2,
                        borderColor: 'gray',
                        borderRadius: 25,
                        alignItems: 'center',
                        justifyContent: 'center'
                    }}
                >
                    <Text style={{
                        color: 'black',
                        fontSize: 16
                    }}>自定义按钮</Text>
                </SFButton>
            </View>
        );
    }
}
1.2.5

6 years ago

1.2.4

6 years ago

1.2.3

6 years ago

1.2.2

6 years ago

1.2.1

6 years ago

1.2.0

6 years ago

1.1.21

6 years ago

1.1.20

6 years ago

1.1.19

6 years ago

1.1.18

6 years ago

1.1.17

6 years ago

1.1.16

6 years ago

1.1.15

6 years ago

1.1.5

6 years ago

1.1.4

6 years ago

1.1.3

6 years ago

1.1.1

6 years ago

1.1.0

6 years ago

1.0.9

6 years ago

1.0.8

6 years ago

1.0.7

6 years ago

1.0.6

6 years ago

1.0.5

6 years ago

1.0.4

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago