Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/57.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
React native 如何设置抽屉内容的样式?_React Native_React Navigation - Fatal编程技术网

React native 如何设置抽屉内容的样式?

React native 如何设置抽屉内容的样式?,react-native,react-navigation,React Native,React Navigation,我只是想给我抽屉里的东西做个样式。我目前有一个主页和设置屏幕,我只想在菜单上设置文本的样式 我尝试过使用contentOptions,但删除了它,因为它不起作用,可能是我放错了它的结构。请帮忙 import * as React from 'react'; import { Text, View, Image, ScrollView, StyleSheet } from 'react-native'; import { createDrawerNavigator, createAppCo

我只是想给我抽屉里的东西做个样式。我目前有一个主页和设置屏幕,我只想在菜单上设置文本的样式

我尝试过使用contentOptions,但删除了它,因为它不起作用,可能是我放错了它的结构。请帮忙

import * as React from 'react';
import { Text, View, Image, ScrollView, StyleSheet } from 'react-native';
import {
  createDrawerNavigator,
  createAppContainer,
  DrawerItems,
  SafeAreaView,
  contentOptions
} from 'react-navigation';
import home from './home'
import SettingScreen from './SettingScreen'

class Home extends React.Component {


  render() {
    return (
      <View style={styles.container}>
        <Map/> 
      </View>
    );
  }
}





const Navigator = createDrawerNavigator(
  {
    Home: {
    screen: home
  },

   Settings: {

 screen: SettingScreen  

   },
    contentOptions : {

color:'White'
},
      },

  {

    drawerBackgroundColor: '#262A2C',

  }
);

 export default createAppContainer(Navigator);

const styles = StyleSheet.create({
  container: {
    flex: 1,
    justifyContent: 'center',
    backgroundColor: '#ecf0f1',

  }
});
import*as React from'React';
从“react native”导入{文本、视图、图像、滚动视图、样式表};
进口{
createDrawerNavigator,
createAppContainer,
付款人,
安全区域视图,
内容选项
}从“反应导航”;
从“./主页”导入主页
从“./SettingScreen”导入设置屏幕
类Home扩展了React.Component{
render(){
返回(
);
}
}
const Navigator=createDrawerNavigator(
{
主页:{
屏幕:主页
},
设置:{
屏幕:设置屏幕
},
内容选项:{
颜色:'白色'
},
},
{
抽屉背景颜色:“#262A2C”,
}
);
导出默认createAppContainer(导航器);
const styles=StyleSheet.create({
容器:{
弹性:1,
为内容辩护:“中心”,
背景颜色:“#ecf0f1”,
}
});

如果要在
RouteConfigs
中添加
contentOptions
contentOptions
应添加到
DrawerNavigatorConfig

const RouteConfigs = {
  Home: {
    screen: Home,
  },

  Settings: {
    screen: SettingScreen,
  },
};

const DrawerNavigatorConfig = {
  intialRouteName: 'Home',
  navigationOptions: {
    headerStyle: {
      backgroundColor: '#f4511e',
    },
    headerTintColor: '#fff',
    headerTitleStyle: {
      color: 'white',
    },
  },
  contentOptions: {
    // add your styling here 
    activeTintColor: '#e91e63',
    itemsContainerStyle: {
      marginVertical: 0,
    },
    iconContainerStyle: {
      opacity: 1,
    },
  },
  drawerBackgroundColor: '#262A2C', // sets background color of drawer
};

const Navigator = createDrawerNavigator(RouteConfigs, DrawerNavigatorConfig);

您能与
contentOptions
共享代码吗?因为它应该可以工作@阿卜杜拉布拉杜萨马托夫