我在我的React Native應用程序中實現React Navigation,並且我想要更改標題的背景和前景顏色。我有以下幾種:React Native,更改React導航標題樣式
/**
* Sample React Native App
* https://github.com/facebook/react-native
* @flow
*/
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
import { StackNavigator } from 'react-navigation';
export default class ReactNativePlayground extends Component {
static navigationOptions = {
title: 'Welcome',
};
render() {
return (
<View style={styles.container}>
<Text style={styles.welcome}>
Welcome to React Native!
</Text>
<Text style={styles.instructions}>
To get started, edit index.android.js
</Text>
<Text style={styles.instructions}>
Double tap R on your keyboard to reload,{'\n'}
Shake or press menu button for dev menu
</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
justifyContent: 'center',
alignItems: 'center',
backgroundColor: '#F5FCFF',
},
welcome: {
fontSize: 20,
textAlign: 'center',
margin: 10,
},
instructions: {
textAlign: 'center',
color: '#333333',
marginBottom: 5,
},
});
const SimpleApp = StackNavigator({
Home: { screen: ReactNativePlayground }
});
AppRegistry.registerComponent('ReactNativePlayground',() => SimpleApp);
默認情況下,標題的背景顏色是白色,前景爲黑色。我也查看了React Navigation的文檔,但是我無法找到它在哪裏顯示如何設置樣式。任何幫助?
衛生署!我正在查看文檔的錯誤部分。謝謝 – Tiwaz89
沒問題,我昨天剛剛這樣做的事實是我能夠提供幫助的唯一原因。我不得不沖刷文檔來找到它。我很高興這並非一帆風順。如果您的ReactNavigation問題太多,請查看4。ReactRouter的0分支,它有本地綁定。 – cssko
真棒我想我會這樣做,再次感謝! :) – Tiwaz89