2017-10-06 66 views
0

我在組件中使用了navigatioinOptions。在反應本機中使用navigationOptions

問題是當我使用navigationOptions時,空間總是離開。

這裏是我的代碼:

static navigationOptions = ({ navigation }) => { 
return { 
    headerLeft: ... 
    } 
} 

我附上圖像文件。

請幫幫我。 謝謝你的時間。 enter image description here

+0

添加'headerRight',但保持爲空:'返回'例如 –

+0

它不適用於我。 –

回答

1

假設你的截圖代表headerLeft獨自一人,因此佈局不符合典型headerLeft |標題| headerRight安排,我建議你把所有這些元素融入header孤單。這樣,你就會有你需要的任何東西,即整個空間:它看起來像

static navigationOptions = ({ navigation }) => { 
    return { 
    header: (
     <View 
     style={{ 
      backgroundColor: "red", 
      paddingTop: 21, 
     }} 
     > 
     <View style={{ backgroundColor: "yellow" }}> 
      <Text>This is 100% wide</Text> 
     </View> 
     </View> 
    ), 
    }; 
}; 

Rendered header

注意,在使用頭這樣你就需要自己照顧所有平臺特定的風格。您可能會發現Header.js' source code對此很有幫助。

+0

它的魅力。謝謝。 –