簡體   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