我只想尝试抽屉里面的内容。我目前有一个主页和SettingsScreen我只想在菜单上设置文本样式
我已经尝试过使用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',
}
});
你在contentOptions
中添加RouteConfigs
,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);