{"id":19631056,"url":"https://github.com/zhangyanlf/rntabbar","last_synced_at":"2025-07-13T19:07:33.766Z","repository":{"id":201623878,"uuid":"119951059","full_name":"zhangyanlf/RNTabbar","owner":"zhangyanlf","description":"Rract-Native       TabBar（Android/iOS按钮突出效果）","archived":false,"fork":false,"pushed_at":"2018-02-05T02:38:28.000Z","size":500,"stargazers_count":8,"open_issues_count":1,"forks_count":5,"subscribers_count":0,"default_branch":"master","last_synced_at":"2025-04-28T06:36:29.869Z","etag":null,"topics":["android","ios","react-native","react-navigation"],"latest_commit_sha":null,"homepage":"","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zhangyanlf.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2018-02-02T07:57:53.000Z","updated_at":"2020-07-01T08:45:21.000Z","dependencies_parsed_at":null,"dependency_job_id":"812d6967-eda3-4375-89c5-ea43439c663c","html_url":"https://github.com/zhangyanlf/RNTabbar","commit_stats":null,"previous_names":["zhangyanlf/rntabbar"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/zhangyanlf/RNTabbar","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangyanlf%2FRNTabbar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangyanlf%2FRNTabbar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangyanlf%2FRNTabbar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangyanlf%2FRNTabbar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zhangyanlf","download_url":"https://codeload.github.com/zhangyanlf/RNTabbar/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zhangyanlf%2FRNTabbar/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":265191117,"owners_count":23725264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["android","ios","react-native","react-navigation"],"created_at":"2024-11-11T12:07:40.974Z","updated_at":"2025-07-13T19:07:33.731Z","avatar_url":"https://github.com/zhangyanlf.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RNTabbar\nTabBar（Android/iOS按钮突出效果）\n\n## 运行工程 \n#### 1.cd进入testTab根目录\n#### 2.npm install\n#### 3.npm start\n#### 4.Xcode/Android Studio 运行项目\n\n## 效果如图\n# ![image](https://github.com/zhangyanlf/RNTabbar/blob/master/testTab/Class/image/iOS效果图.png)  ![image](https://github.com/zhangyanlf/RNTabbar/blob/master/testTab/Class/image/安卓效果图.png)\n\n\n## 实现代码\n``` React-Native\nimport React, { Component } from 'react';\nimport {\n    AppRegistry,\n    Platform,\n    StyleSheet,\n    Text,\n    View,\n    TouchableOpacity,\n    NativeModules,\n    ImageBackground,\n    DeviceEventEmitter\n} from 'react-native';\n\nexport default class Tab extends Component {\n    renderItem = (route, index) =\u003e {\n        const {\n            navigation,\n            jumpToIndex,\n        } = this.props;\n\n        const focused = index === navigation.state.index;\n        const color = focused ? this.props.activeTintColor : this.props.inactiveTintColor;\n        let TabScene = {\n            focused:focused,\n            route:route,\n            tintColor:color\n        };\n\n        if(index === 2){\n            return (\u003cView\n                    key={route.key}\n                    style={[styles.tabItem,{backgroundColor:'transparent'}]}\u003e\n                \u003c/View\u003e\n            );\n        }\n\n        return (\n            \u003cTouchableOpacity\n                key={route.key}\n                style={styles.tabItem}\n                onPress={() =\u003e jumpToIndex(index)}\n            \u003e\n                \u003cView\n                    style={styles.tabItem}\u003e\n                    {this.props.renderIcon(TabScene)}\n                    \u003cText style={{ ...styles.tabText,marginTop:SCALE(10),color }}\u003e{this.props.getLabel(TabScene)}\u003c/Text\u003e\n                \u003c/View\u003e\n            \u003c/TouchableOpacity\u003e\n        );\n    };\n    render(){\n        const {navigation,jumpToIndex} = this.props;\n        const {routes,} = navigation.state;\n        const focused = 2 === navigation.state.index;\n        const color = focused ? this.props.activeTintColor : this.props.inactiveTintColor;\n        let TabScene = {\n            focused:focused,\n            route:routes[2],\n            tintColor:color\n        };\n        return (\u003cView style={{width:WIDTH}}\u003e\n            \u003cView style={styles.tab}\u003e\n                {routes \u0026\u0026 routes.map((route,index) =\u003e this.renderItem(route, index))}\n            \u003c/View\u003e\n            {/*设置中间按钮凸出样式  使用绝对定位*/}\n            \u003cTouchableOpacity\n                key={\"centerView\"}\n\n                style={[styles.tabItem,{position:'absolute',bottom:0,left:(WIDTH-SCALE(100))/2,right:WIDTH-SCALE(100),height:SCALE(120)}]}\n                onPress={() =\u003e jumpToIndex(2)}\u003e\n                \u003cView\n                    style={styles.tabItem}\u003e\n                    {this.props.renderIcon(TabScene)}\n                    \u003cText style={{ ...styles.tabText,marginTop:SCALE(10),color }}\u003e{this.props.getLabel(TabScene)}\u003c/Text\u003e\n                \u003c/View\u003e\n            \u003c/TouchableOpacity\u003e\n        \u003c/View\u003e);\n    }\n}\nconst styles = {\n    tab:{\n        width:WIDTH,\n        backgroundColor:'transparent',\n        flexDirection:'row',\n        justifyContent:'space-around',\n        alignItems:'flex-end'\n    },\n    tabItem:{\n        height:SCALE(80),\n        width:SCALE(100),\n        alignItems:'center',\n        justifyContent:'center'\n    },\n    tabText:{\n        marginTop:SCALE(13),\n        fontSize:FONT(10),\n        color:'#7b7b7b'\n    },\n    tabTextChoose:{\n        color:'#f3474b'\n    },\n    tabImage:{\n        width:SCALE(42),\n        height:SCALE(42),\n    },\n};\n\n```\n\n####  推荐react-navigation 中文翻译：  [zhangyanlf]: https://www.reactnavigation.org.cn\n\n## PS：运用 react-navigation 是问题记录\n#### 1.Android 导航栏文字居中效果\n#### node_modules -- react-navigation -- src -- views -- Header -- Header.js 修改368行 将  alignItems: Platform.OS === 'ios' ? 'center' : 'flex-start' 改为 'center'即可 （遇到的问题后续还会持续更新）\n```\ntitle: {\n        bottom: 0,\n        left: TITLE_OFFSET,\n        right: TITLE_OFFSET,\n        top: 0,\n        position: 'absolute',\n        alignItems: 'center'//Platform.OS === 'ios' ? 'center' : 'flex-start',\n  }\n```\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhangyanlf%2Frntabbar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzhangyanlf%2Frntabbar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzhangyanlf%2Frntabbar/lists"}