React native 如何使用react导航&x27;s头左和头右
使用react导航,发现headerLeft没有响应?没有头左,头右React native 如何使用react导航&x27;s头左和头右,react-native,React Native,使用react导航,发现headerLeft没有响应?没有头左,头右 class Message extends React.Component { static navigationOptions = { tabBarLabel: '消息', headerTitle: () => ( <View style={styles.headerWrapper}> <Text adjustsFontSize
class Message extends React.Component {
static navigationOptions = {
tabBarLabel: '消息',
headerTitle: () => (
<View style={styles.headerWrapper}>
<Text
adjustsFontSizeToFit
style={styles.headerText}>消息</Text>
</View>
),
tabBarIcon: ({ focused, tintColor }) => (
<Image
source={focused ? require('../images/clickmessage.png') :
require('../images/message.png')}
style={{ width: 26, height: 26, tintColor: tintColor }}
/>
),
headerLeft: ({ focused, tinColor }) => {
<Image
source={focused ? require('../images/clickmessage.png') :
require('../images/message.png')}
style={{ width: 26, height: 26, tintColor: tintColor }}
/>
}
};
render() {
return (
<View style={styles.container}>
<MessageContent />
</View>
);
}
类消息扩展了React.Component{
静态导航选项={
tabBarLabel:'消息',
标题:()=>(
消息
),
tabBarIcon:({focused,tintColor})=>(
),
headerLeft:({focused,tinColor})=>{
}
};
render(){
返回(
);
}
headerLeft和headerRight是无效的类消息扩展React.Component{
class Message extends React.Component {
static navigationOptions = {
tabBarLabel: '消息',
headerTitle: () => (
<View style={styles.headerWrapper}>
<Text
adjustsFontSizeToFit
style={styles.headerText}>消息</Text>
</View>
),
tabBarIcon: ({ focused, tintColor }) => (
<Image
source={focused ? require('../images/clickmessage.png') :
require('../images/message.png')}
style={{ width: 26, height: 26, tintColor: tintColor }}
/>
),
headerLeft: ({ focused, tinColor }) => {
<Image
source={focused ? require('../images/clickmessage.png') :
require('../images/message.png')}
style={{ width: 26, height: 26, tintColor: tintColor }}
/>
}
};
render() {
return (
<View style={styles.container}>
<MessageContent />
</View>
);
}
静态导航选项={
tabBarLabel:'消息',
标题:()=>(
消息
),
tabBarIcon:({focused,tintColor})=>(
),
headerLeft:({focused,tinColor})=>{
}
};
render(){
返回(
);
}
}类消息扩展了React.Component{
静态导航选项={
tabBarLabel:'消息',
标题:()=>(
消息
),
tabBarIcon:({focused,tintColor})=>(
),
headerLeft:({focused,tinColor})=>{
}
};
render(){
返回(
);
}
}您可以像这样使用左右标题:
static navigationOptions = ({navigation}) => {
return {
headerTitle: (
<View style={{flex: 1, alignSelf: 'center'}}>
<AppFontLoader>
<Text style={{
color: '#fff',
alignSelf: 'center',
...Platform.select({
ios: {
fontFamily: 'Some implemented font',
},
android: {
fontFamily: 'Another font for android',
}
}),
}}>Place you title here</Text>
</AppFontLoader>
</View>
),
headerRight: (
<TouchableOpacity onPress={() => navigation.navigate({routeName: 'PriceList'})}
style={{right: Platform.OS === 'ios' ? Dimensions.get("window").height < 667 ? '10%' : '5%' : '25%', backgroundColor: 'transparent', paddingLeft: 15}}>
<Image style={{width: 25, height: 25}} source={require('../../assets/icons/info2.png')}/>
</TouchableOpacity>
),
headerLeft: (
<TouchableOpacity onPress={() => navigation.goBack(null)} style={{left: Dimensions.get("window").height < 667 ? '8%' : '3%', backgroundColor: 'red', width: '100%'}}>
<Image style={{width: 30, height: 30}} source={require('../../assets/icons/back-icon-50x50.png')}/>
</TouchableOpacity>
),
headerStyle: {
backgroundColor: '#14b6e4',
},
headerTintColor: '#fff',
};
};
静态导航选项=({navigation})=>{
返回{
标题:(
把你的头衔放在这里
),
头灯:(
导航({routeName:'PriceList'})}
style={{right:Platform.OS=='ios'?Dimensions.get(“window”)。高度<667?'10%:'5%:'25%,'backgroundColor:'transparent',paddingLeft:15}>
),
左校长:(
navigation.goBack(null)}style={{left:Dimensions.get(“window”)。高度<667?'8%:'3%',背景色:'red',宽度:'100%}>
),
头型:{
背景颜色:“#14b6e4”,
},
标题颜色:“#fff”,
};
};
您可以像这样使用左右标题:
static navigationOptions = ({navigation}) => {
return {
headerTitle: (
<View style={{flex: 1, alignSelf: 'center'}}>
<AppFontLoader>
<Text style={{
color: '#fff',
alignSelf: 'center',
...Platform.select({
ios: {
fontFamily: 'Some implemented font',
},
android: {
fontFamily: 'Another font for android',
}
}),
}}>Place you title here</Text>
</AppFontLoader>
</View>
),
headerRight: (
<TouchableOpacity onPress={() => navigation.navigate({routeName: 'PriceList'})}
style={{right: Platform.OS === 'ios' ? Dimensions.get("window").height < 667 ? '10%' : '5%' : '25%', backgroundColor: 'transparent', paddingLeft: 15}}>
<Image style={{width: 25, height: 25}} source={require('../../assets/icons/info2.png')}/>
</TouchableOpacity>
),
headerLeft: (
<TouchableOpacity onPress={() => navigation.goBack(null)} style={{left: Dimensions.get("window").height < 667 ? '8%' : '3%', backgroundColor: 'red', width: '100%'}}>
<Image style={{width: 30, height: 30}} source={require('../../assets/icons/back-icon-50x50.png')}/>
</TouchableOpacity>
),
headerStyle: {
backgroundColor: '#14b6e4',
},
headerTintColor: '#fff',
};
};
静态导航选项=({navigation})=>{
返回{
标题:(
把你的头衔放在这里
),
头灯:(
导航({routeName:'PriceList'})}
style={{right:Platform.OS=='ios'?Dimensions.get(“window”)。高度<667?'10%:'5%:'25%,'backgroundColor:'transparent',paddingLeft:15}>
),
左校长:(
navigation.goBack(null)}style={{left:Dimensions.get(“window”)。高度<667?'8%:'3%',背景色:'red',宽度:'100%}>
),
头型:{
背景颜色:“#14b6e4”,
},
标题颜色:“#fff”,
};
};
你到底想做什么?你能给我们看看你试过的代码吗?什么不起作用?你到底想做什么?你能给我们看看你试过的代码吗?到底什么不起作用?请尝试删除此属性并以另一种方式操作({focused,tinColor})=>尝试删除此属性并以另一种方式操作({focused,tinColor})=>