2016-12-29 44 views
1

這是我的第一個問題,所以請原諒我如果我犯了什麼錯誤。反應原生路由器Flux定製圖標

我想自定義IOS的導航欄圖標使用React本地路由器通量,但我不知道如何檢索我自定義的圖標(PNG文件)在一些例子中,他們使用圖標= {tabIcon}像這樣但我需要做的是描述圖像源的路徑,但我不知道如何以正確的語法輸入它。

任何幫助,將不勝感激。謝謝。

這裏是我的代碼:

 <Scene key="root"> 
     <Scene key="tabbar" tabs> 

      <Scene key="tab2" title="Categories" **icon={TabIcon}** > 
      <Scene key="categories" component={Categories} title="Categories" initial /> 
      <Scene hideTabBar key="categorylisting" component={CategoryListing} title="Adventure" /> 
      <Scene hideTabBar key="showdetails" component={ShowDetails} title="TV Show Details" /> 
      </Scene> 

回答

3

這似乎是從文檔丟失,但它這樣做。

function CustomIcon(props) { 
    return (
    <View> 
     <Image 
     source={iconSource} 
     style={{ width: 22, height: 25 }} 
     tintColor={'red'} 
     /> 
     <Text>Tab1</Text> 
    </View> 
); 
} 

<Scene key="tab1" icon={CustomIcon} > 
</Scene> 
+1

謝謝。我不知道那個icon = {CustomIcon}必須是一個組件。我認爲它可以是一個指定圖標資源路徑的變量。非常感謝。 –