react-native-android - 我想在反应原生的选项卡导航的底部选项卡中添加自定义图标
问题描述
import { createBottomTabNavigator } from 'react-navigation';
我正在导入两个文件
import Profile from './app/profile'
import Home from './app/result'
创建一个有效的底部标签导航,但我只需要显示自定义图标,我可以在其中实际提供图标路径。
export default createBottomTabNavigator
({
Home: { screen: Home },
Profile: { screen: Profile }
},
{
initialRouteName: 'Discovery',
});
有没有办法做到这一点?
解决方案
你可以试试用这个。这是我的代码片段。
ShoutOut: {
screen:ShoutOut,
navigationOptions: {
tabBarLabel: 'ShoutOut',
tabBarIcon: ({tintColor, activeTintColor}) => (
<Icon name="ios-megaphone" size={30} color={tintColor} />
)
},
},
对于你的应该是...
export default createBottomTabNavigator
({
Home: {
screen: Home,
navigationOptions: {
tabBarLabel: 'Home',
tabBarIcon: ({tintColor, activeTintColor}) => (
<Icon name="home" size={30} color={tintColor} />
)
},
},
Profile: {
screen: Profile,
navigationOptions: {
tabBarLabel: 'Profile',
tabBarIcon: ({tintColor, activeTintColor}) => (
<Icon name="user" size={30} color={tintColor} />
)
},
}
},
{
initialRouteName: 'Discovery',
tabBarOptions: {
activeTintColor: '#fb9800',
inactiveTintColor: '#7e7b7b',
showIcon: true,
style: { height: 54,backgroundColor: '#fff',borderTopWidth:0.5,borderTopColor: '#fb9800' },
showLabel: true,
labelStyle: {
fontSize: 10,
}
}
});
推荐阅读
- javascript - React 组件的阶段和 React 组件的生命周期有什么区别?
- python - Django objects.get() 函数不起作用,但 objects.filter().first() 起作用
- java - 元素链接没有重定向到它的目标页面?
- gradle - 如何跟踪泄漏的 Gradle API 依赖项
- python - 尝试使用 pygame 制作游戏的 Python 新手
- swift - 带有资源的 Swift 包管理器编译错误
- vb.net - 在 .NET 上使用 ffplay / ffmpeg 播放 ogg 文件
- reactjs - Error: useRoutes() may be used only in the context of a
component - r - 从闪亮的列表中绘制 dygraph
- docker - Docker BuildX 图像未在 docker image ls 中显示