【发布时间】:2018-06-02 22:47:28
【问题描述】:
我将 DrawerNavigator 集成到我的项目中。它工作正常,但没有任何属性来设置背景图像。如何在 DrawerNavigator 中添加背景图片。
抽屉导航代码
import { AppRegistry , Dimensions} from 'react-native';
import Library from './ViewControllers/Library';
import Language from './ViewControllers/Language';
import AboutUS from './ViewControllers/AboutUS';
import Support from './ViewControllers/Support';
import { DrawerNavigator } from 'react-navigation';
const MyApp = DrawerNavigator({
Library: {
screen: Library,
},
Language: {
screen: Language,
},
AboutUS: {
screen: AboutUS,
},
Support: {
screen: Support,
},
},{
initialRouteName:'Library',
drawerWidth: Dimensions.get('window').width / 2.0,
drawerPosition: 'left',
useNativeAnimations : false,
drawerBackgroundColor : 'white',
contentOptions: {
activeTintColor: 'black',
activeBackgroundColor : 'transparent',
inactiveTintColor : 'black',
itemsContainerStyle: {
marginVertical: 0,
},
iconContainerStyle: {
opacity: 1
},
itemStyle :{
height : 50,
}
},
}
);
AppRegistry.registerComponent('Basair', () => MyApp);
【问题讨论】:
-
非常好的问题 =) 我不知道该怎么做。也许用抽屉宽度做简单的方法:'100%',然后分成两半以在右侧显示图像?
-
@Val,但没有任何默认属性。
-
哪个属性?在这里检查,
drawerWidth可以设置为drawerWidth: '100%'reactnavigation.org/docs/navigators/… -
我将设置drawerWidth: '100%' 然后它会占用整个项目的宽度。
-
@Val,是的,我使用 contentComponent 解决了。reactnavigation.org/docs/navigators/…
标签: react-native navigation-drawer react-native-android react-native-ios stack-navigator