繁体   English   中英

反应本机stackNavigation标头

[英]react native stackNavigation header

我在react-native中的stackNavigator附带的标头面临一个小问题。

我有两个视图,分别是Skatebay和Profile。 当我使用stackNavigator时,它会在Skatebay视图中添加一个顶部的“标题”,如果不能的话,如何删除它,我是否可以将其样式设置为已经创建的标题?

import React, { Component } from 'react';
import {
  AppRegistry,
  StyleSheet,
  Text,
  View,
  TouchableHighlight,
  Image,
  ScrollView,
  Button,
} from 'react-native';
import { StackNavigator } from 'react-navigation';
import s from './styles/main.js';

class skatebay extends React.Component{

  render(){
    const { navigate } = this.props.navigation;
    return (

  <View style={s.container}>

      <View style={s.toolbar}>
        <TouchableHighlight style={s.toolbarButton} onPress={() => navigate('Profile')}
          title="Profile">
          <Image style={s.toolIcon} source={require('./gfx/profile.png')}/>
        </TouchableHighlight>

        <TouchableHighlight style={s.toolbarTitle} onPress={alert}>
          <Image style={s.logo} source={require('./gfx/logos.png')}/>
        </TouchableHighlight>

        <TouchableHighlight style={s.toolbarButton} onPress={alert}>
          <Image style={s.toolIcon} source={require('./gfx/settings.png')}/>
        </TouchableHighlight>
      </View>

      </View>
    );
    }
}


个人资料视图

class ProfileScreen extends React.Component {
    static navigationOptions = {
        title: 'Profile',
    };
render() {
    return (
      <View>
        <Text>profile</Text>
      </View>
    );
  }
}


const skatebayApp = StackNavigator({
  Main: {screen: skatebay},
  Profile: {screen: ProfileScreen}
});

AppRegistry.registerComponent('skatebayApp', () => skatebayApp);

我说的是我创建的白色标头上方的蓝色/灰色标头。

在此处输入图片说明

如果您不希望使用StackNavigator的默认标头,则可以不将其传递给StackNavigatorConfig https://reactnavigation.org/docs/navigators/stack#StackNavigatorConfig

const skatebayApp = StackNavigator({
  Main: {screen: skatebay},
  Profile: {screen: ProfileScreen}
}, {
  headerMode: 'none'
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM