React Native懸浮按鈕組件:react-native-action-button,純JS組件,支持安卓和IOS雙平臺(tái),支持設(shè)置子按鈕,支持自定義位置和樣式和圖標(biāo)。
效果圖
安裝方法
npm i react-native-action-button --save react-native link react-native-vector-icons
因?yàn)橛玫搅藃eact-native-vector-icons圖標(biāo)組件,需要做下link。如果你項(xiàng)目中已經(jīng)使用了react-native-vector-icons,那就不需要這步了。
示例代碼
<View style={styles.container}> <Text style={styles.welcome}> 懸浮按鈕組件示例 </Text> <ActionButton buttonColor="rgba(231,76,60,1)" position='left' verticalOrientation='up'> <ActionButton.Item buttonColor='#9b59b6' title="New Task" onPress={() => console.log("notes tapped!")}> <Icon name="ios-create-outline" style={styles.actionButtonIcon} /> </ActionButton.Item> <ActionButton.Item buttonColor='#3498db' title="Notifications" onPress={() => {}}> <Icon name="ios-notifications-off" style={styles.actionButtonIcon} /> </ActionButton.Item> <ActionButton.Item buttonColor='#1abc9c' onPress={() => {}}> <Icon name="ios-done-all-outline" style={styles.actionButtonIcon} /> </ActionButton.Item> </ActionButton> <ActionButton buttonColor="rgba(231,76,60,1)" onPress={() => { alert('你點(diǎn)了我!')}} renderIcon={() => (<View style={styles.actionButtonView}><Icon name="ios-create-outline" style={styles.actionButtonIcon} /> <Text style={styles.actionButtonText}>新增</Text> </View>)} /> </View>
主要參數(shù)說(shuō)明
ActionButton
ActionButton.Item
完整示例
完整代碼:GitHub - forrest23/ReactNativeComponents: React Native組件大全
本次示例代碼在 Component10文件夾中。
組件地址
GitHub - mastermoo/react-native-action-button: customizable multi-action-button component for react-native
聲明:本網(wǎng)頁(yè)內(nèi)容旨在傳播知識(shí),若有侵權(quán)等問(wèn)題請(qǐng)及時(shí)與本網(wǎng)聯(lián)系,我們將在第一時(shí)間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com