我是新来的本地人。我试图添加一个抽屉式导航器,默认情况下它是蓝色的,是否可以更改此颜色?我正在使用本机基础库,这是我的代码的屏幕截图和摘要,以阐明我的要求。谢谢 我的app.js中的抽屉组件的结构如下:
const CustomDrawerComponent = (props) => (
<SafeAreaView style={{ flex:1, marginTop:12 }}>
<View style={{ height: 150, backgroundColor: 'white', alignItems: 'center', justifyContent:'center' }}>
<Image source={require('./assets/icon.png')} style={{height:120,width:120,borderRadius:60}}/>
</View>
<ScrollView>
<DrawerItems {...props}/>
</ScrollView>
</SafeAreaView>
)
这里也是屏幕之一:
class LibraryScreen extends React.Component {
static navigationOptions = {
drawerIcon : ({tintColor}) => (
<Icon name="home" style={{fontSize:24, color:tintColor}}/>
)
}
render() {
return (
<View style={styles.container}>
<Header>
<Left style={{justifyContent:"flex-start",flex:1,marginTop:20}}>
<Icon name="menu" onPress={()=>this.props.navigation.openDrawer()}/>
</Left>
</Header>
<View style={{flex:1, alignItems:'center', justifyContent:'center'}}>
<Text>Library Screen</Text>
</View>
</View>
);
}
}
export default LibraryScreen;
答案 0 :(得分:0)
为<Header>
组件添加样式
<Header
style={{
backgroundColor: 'red',
}}>
完整代码
class LibraryScreen extends React.Component {
static navigationOptions = {
drawerIcon : ({tintColor}) => (
<Icon name="home" style={{fontSize:24, color:tintColor}}/>
)
}
render() {
return (
<View style={styles.container}>
<Header
style={{ backgroundColor: 'red' }}>
<Left style={{justifyContent:"flex-start",flex:1,marginTop:20}}>
<Icon name="menu" onPress={()=>this.props.navigation.openDrawer()}/>
</Left>
</Header>
<View style={{flex:1, alignItems:'center', justifyContent:'center'}}>
<Text>Library Screen</Text>
</View>
</View>
);
}
}
导出默认的LibraryScreen;