<span id="mktg5"></span>

<i id="mktg5"><meter id="mktg5"></meter></i>

        <label id="mktg5"><meter id="mktg5"></meter></label>
        最新文章專題視頻專題問答1問答10問答100問答1000問答2000關鍵字專題1關鍵字專題50關鍵字專題500關鍵字專題1500TAG最新視頻文章推薦1 推薦3 推薦5 推薦7 推薦9 推薦11 推薦13 推薦15 推薦17 推薦19 推薦21 推薦23 推薦25 推薦27 推薦29 推薦31 推薦33 推薦35 推薦37視頻文章20視頻文章30視頻文章40視頻文章50視頻文章60 視頻文章70視頻文章80視頻文章90視頻文章100視頻文章120視頻文章140 視頻2關鍵字專題關鍵字專題tag2tag3文章專題文章專題2文章索引1文章索引2文章索引3文章索引4文章索引5123456789101112131415文章專題3
        問答文章1 問答文章501 問答文章1001 問答文章1501 問答文章2001 問答文章2501 問答文章3001 問答文章3501 問答文章4001 問答文章4501 問答文章5001 問答文章5501 問答文章6001 問答文章6501 問答文章7001 問答文章7501 問答文章8001 問答文章8501 問答文章9001 問答文章9501
        當前位置: 首頁 - 科技 - 知識百科 - 正文

        詳解React Native頂|底部導航使用小技巧

        來源:懂視網(wǎng) 責編:小采 時間:2020-11-27 22:30:01
        文檔

        詳解React Native頂|底部導航使用小技巧

        詳解React Native頂|底部導航使用小技巧:導航一直是App開發(fā)中比較重要的一個組件,ReactNative提供了兩種導航組件供我們使用,分別是:NavigatorIOS和Navigator,但是前者只能用于iOS平臺,后者在ReactNative0.44版本以后已經(jīng)被移除了。 好在有人提供了更好的導航組件,就是我們今天要講的react
        推薦度:
        導讀詳解React Native頂|底部導航使用小技巧:導航一直是App開發(fā)中比較重要的一個組件,ReactNative提供了兩種導航組件供我們使用,分別是:NavigatorIOS和Navigator,但是前者只能用于iOS平臺,后者在ReactNative0.44版本以后已經(jīng)被移除了。 好在有人提供了更好的導航組件,就是我們今天要講的react

        導航一直是App開發(fā)中比較重要的一個組件,ReactNative提供了兩種導航組件供我們使用,分別是:NavigatorIOS和Navigator,但是前者只能用于iOS平臺,后者在ReactNative0.44版本以后已經(jīng)被移除了。

        好在有人提供了更好的導航組件,就是我們今天要講的react-navigation,并且ReactNative官方更推薦我們使用此組件。

        本篇文章只講解基礎用法,如果你想了解更多,請戳這里->戳我。

         簡介

        react-navigation主要包括導航,底部tab,頂部tab,側滑等,分別為:

      1. 導航 -> StackNavigator
      2. 底部或者頂部tab -> TabNavigator
      3. 側滑 -> DrawerNavigator
      4. 我們今天主要講TabNavigator。

        效果展示

         實現(xiàn)代碼

        import React, { Component } from 'react';
        import {
         AppRegistry,
         StyleSheet,
         Button,
         Text,
         View,
         Image,
         StatusBar
        } from 'react-native';
        import { StackNavigator, TabBarBottom, TabNavigator } from "react-navigation";
        
        
        class Home extends React.Component {
         static navigationOptions = {
         tabBarLabel: '熱點',
         tabBarIcon: ({ focused, tintColor }) => (
         <Image
         source={focused ? require('../res/images/hot_hover.png') : require('../res/images/hot.png')}
         style={{ width: 26, height: 26, tintColor: tintColor }}
         />
         )
         };
         render() {
         return (
         <View style={styles.container}>
         <Text>!這是熱點</Text>
         </View>
         );
         }
        }
        
        class Circle extends React.Component {
         static navigationOptions = {
         tabBarLabel: '圈子',
         tabBarIcon: ({ focused, tintColor }) => (
         <Image
         source={focused ? require('../res/images/coterie.png') : require('../res/images/coterie.png')}
         style={{ width: 26, height: 26, tintColor: tintColor }}
         />
         )
         };
         render() {
         return (
         <View style={styles.container}>
         <Text>!這是圈子</Text>
         </View>
         );
         }
        }
        
        class Tools extends React.Component {
         static navigationOptions = {
         tabBarLabel: '工具',
         tabBarIcon: ({ focused, tintColor }) => (
         <Image
         source={focused ? require('../res/images/tool.png') : require('../res/images/tool.png')}
         style={{ width: 26, height: 26, tintColor: tintColor }}
         />
         )
         };
         render() {
         return (
         <View style={styles.container}>
         <Text>!這是工具</Text>
         </View>
         );
         }
        }
        
        class Mypage extends React.Component {
         static navigationOptions = {
         tabBarLabel: '我的',
         tabBarIcon: ({ focused, tintColor }) => (
         <Image
         source={focused ? require('../res/images/my_hover.png') : require('../res/images/my.png')}
         style={{ width: 26, height: 26, tintColor: tintColor }}
         />
         )
         };
         render() {
         return (
         <View style={styles.container}>
         <Text>!這是我的</Text>
         </View>
         );
         }
        }
        
        const styles = StyleSheet.create({
         container: {
         flex: 1,
         justifyContent: 'center',
         alignItems: 'center',
         backgroundColor: '#fff',
         }
        });
        
        
        const MyApp = TabNavigator(
         {
         Home: {
         screen: Home,
         },
         Circle: {
         screen: Circle,
         },
         Tools: {
         screen: Tools,
         },
         Mypage: {
         screen: Mypage,
         },
         },
         {
         tabBarOptions: {
         activeTintColor: '#4BC1D2',
         inactiveTintColor: '#000',
         showIcon: true,
         showLabel: true,
         upperCaseLabel: false,
         pressColor: '#823453',
         pressOpacity: 0.8,
         style: {
         backgroundColor: '#fff',
         paddingBottom: 0,
         borderTopWidth: 0.5,
         borderTopColor: '#ccc',
         },
         labelStyle: {
         fontSize: 12,
         margin: 1
         },
         indicatorStyle: { height: 0 }, //android 中TabBar下面會顯示一條線,高度設為 0 后就不顯示線了
         },
         tabBarPosition: 'bottom',
         swipeEnabled: false,
         animationEnabled: false,
         lazy: true,
         backBehavior: 'none',
         });
        
        module.exports = MyApp;
        
        

        配置說明

        NavigationOptions

        當然,通過NavigationOptions來配置我們的tabBarItem:

      5. title - 標題
      6. tabBarVisible - 是否可見
      7. tabBarIcon - 配置圖片,當然,完全可以不使用圖片
      8. tabBarLabel - 也是配置標題,只不過title既能配置tab的標題,也能配置navigation的標題
      9.  TabNavigatorConfig

      10. tabBarComponent- 用作標簽欄的組件,例如 (這是iOS上的默認設置), (這是Android上的默認設置)TabBarBottomTabBarTop
      11. tabBarPosition- 標簽欄的位置可以是或'top''bottom'
      12. swipeEnabled - 是否允許在標簽之間進行滑動
      13. animationEnabled - 是否在更改標簽時動畫
      14. lazy - 是否根據(jù)需要懶惰呈現(xiàn)標簽,而不是提前制作
      15. tabBarOptions - 配置標簽欄,如下所示。
      16. 幾個選項被傳遞到底層路由器來修改導航邏輯:
      17. initialRouteName - 首次加載時初始標簽路由的routeName
      18. order - 定義選項卡順序的routeNames數(shù)組
      19. paths - 將routeName映射到路徑配置,該配置將覆蓋routeConfigs中設置的路徑。
      20. backBehavior - 后退按鈕是否會使Tab鍵切換到初始選項卡?如果是,否則設置。默認為行為。initialRoutenoneinitialRoute
      21. tabBarOptions for (iOS上的默認標簽欄)TabBarBottom

      22. activeTintColor - 活動標簽的標簽和圖標顏色
      23. activeBackgroundColor - 活動選項卡的背景顏色
      24. inactiveTintColor - 非活動標簽的標簽和圖標顏色
      25. inactiveBackgroundColor - 非活動標簽的背景顏色
      26. showLabel - 是否顯示標簽的標簽,默認為true
      27. style - 標簽欄的樣式對象
      28. labelStyle - 標簽標簽的樣式對象
      29. tabStyle - 標簽的樣式對象
      30. tabBarOptions for (Android上的默認標簽欄)TabBarTop

      31. activeTintColor - 活動標簽的標簽和圖標顏色
      32. inactiveTintColor - 非活動標簽的標簽和圖標顏色
      33. showIcon - 是否顯示標簽的圖標,默認值為false
      34. showLabel - 是否顯示標簽的標簽,默認為true
      35. upperCaseLabel - 是否使標簽大寫,默認為true
      36. pressColor - 材質波紋顏色(Android> = 5.0)
      37. pressOpacity - 按壓標簽的不透明度(iOS和Android <5.0 only)
      38. scrollEnabled - 是否啟用可滾動選項卡
      39. tabStyle - 標簽的樣式對象
      40. indicatorStyle - 標簽指示器的樣式對象(選項卡底部的行)
      41. labelStyle - 標簽標簽的樣式對象
      42. iconStyle - 標簽圖標的樣式對象
      43. style - 標簽欄的樣式對象
      44. 小技巧

        1.去掉安卓下的下劃線,設置:tabBarOptions => indicatorStyle:{ height: 0 };

        2.底部導航在導航最上方添加一條分割線,設置:tabBarOptions => style => borderTopWidth: 0.5, borderTopColor: '#ccc';

        3.導航安卓圖標和文字間隙比較大,手動調整小設置:tabBarOptions => labelStyle => margin: 0;

        聲明:本網(wǎng)頁內容旨在傳播知識,若有侵權等問題請及時與本網(wǎng)聯(lián)系,我們將在第一時間刪除處理。TEL:177 7030 7066 E-MAIL:11247931@qq.com

        文檔

        詳解React Native頂|底部導航使用小技巧

        詳解React Native頂|底部導航使用小技巧:導航一直是App開發(fā)中比較重要的一個組件,ReactNative提供了兩種導航組件供我們使用,分別是:NavigatorIOS和Navigator,但是前者只能用于iOS平臺,后者在ReactNative0.44版本以后已經(jīng)被移除了。 好在有人提供了更好的導航組件,就是我們今天要講的react
        推薦度:
        • 熱門焦點

        最新推薦

        猜你喜歡

        熱門推薦

        專題
        Top
        主站蜘蛛池模板: 免费无码一区二区三区蜜桃大| 免费观看美女用震蛋喷水的视频| 日本人护士免费xxxx视频| 免费国产成人α片| 亚洲午夜av影院| 91在线视频免费观看| 亚洲人成网亚洲欧洲无码久久 | 亚洲一卡二卡三卡| 57pao一国产成视频永久免费| 国产精品色午夜免费视频| 国产成人综合亚洲AV第一页 | 亚洲日本成本人观看| 免费高清av一区二区三区| 亚洲av片在线观看| 亚洲国产成人精品女人久久久| 一级毛片免费观看不收费| 亚洲综合亚洲综合网成人| a成人毛片免费观看| 亚洲天堂在线播放| 色窝窝免费一区二区三区 | 日本永久免费a∨在线视频| 一级毛片全部免费播放| 亚洲不卡视频在线观看| 免费人成在线观看播放国产| 久久毛片免费看一区二区三区| 午夜a级成人免费毛片| 亚洲av综合日韩| 亚洲中文字幕无码永久在线| 91免费国产精品| 亚洲欧美综合精品成人导航| 亚洲国产一成久久精品国产成人综合| 一本色道久久88—综合亚洲精品 | 亚洲中文字幕无码爆乳| 国产成人高清精品免费鸭子| 久久免费观看视频| 亚洲sss综合天堂久久久| 日韩中文字幕精品免费一区| 亚洲视频免费观看| 国产又大又粗又硬又长免费 | 久草福利资源网站免费| 涩涩色中文综合亚洲|