【问题标题】:StackNavigator inside TabNavigator can't change nav bar colorTabNavigator 中的 StackNavigator 无法更改导航栏颜色
【发布时间】:2018-03-30 03:43:34
【问题描述】:

我有一个 StackNavigator:

const infoNavigator = StackNavigator({
InfoMain: {
    screen: PFInfoMain,
    navigationOptions: {
        title: 'Information',
        tintColor: 'red'
    }
},
InfoDetail: {screen: PFInfoDetail}
});

TabNavigator 内部:

iOS:

const iosTabs = TabNavigator({
Info: {
    screen: infoNavigator,
    navigationOptions: {
        tabBarLabel: 'Info',
        tabBarIcon: ({tintColor}) => (
            <Image
                source={require('../assets/home.png')}
                style={[styles.icon, {tintColor: tintColor}]}
            />
        )
    }
}...

安卓:

const androidTabs = TabNavigator(
{
    Info: {screen: infoNavigator} ...

infoNavigator 中带有 tintColor: 'red' 的 navigationOptions 只是设置导航栏(标题?)颜色的无数次失败尝试之一。

没有任何效果。

有人可以帮忙吗?谢谢!

【问题讨论】:

    标签: react-native


    【解决方案1】:

    假设您使用的是react-navigation

    在他们的docs 中没有提到tintColor 这样的东西。

    用户headerTintColorheaderStyle

    static navigationOptions = ({ navigation, screenProps }) => ({
           headerTintColor: "red",
           headerStyle: {
             backgroundColor:"red"
           }
       });
    

    【讨论】:

    • headerTintColor 更改导航栏中的文本颜色。
    • 更新了答案。
    • 做到了!谢谢!我发誓我之前已经尝试过,并且收到了关于不允许在那里放置对象或其他东西的错误。再次感谢
    猜你喜欢
    • 2016-06-03
    • 1970-01-01
    • 1970-01-01
    • 2018-02-06
    • 2014-09-14
    • 1970-01-01
    相关资源
    最近更新 更多