1
A
回答
1
,如果你是使用反應母語矢量圖標是非常容易,只需創建一個像我下面創建的,您要使用的圖標的所有名稱,如果你在一個數組想要使用圖像,那麼你將不得不使用圖像鏈接,因爲我最後一次檢查反應原生不會讓你動態加載靜態資產。
效益使用圖標尤其反應天然載體圖標的:
- 訪問圖標集的噸。
- 樣式基於它的焦點與否。
- ....和其他我不記得的東西。
`
.....
import Icon from 'react-native-vector-icons/Ionicons';
const styles = {
body: {
backgroundColor: '#3b4147',
height: 60,
},
tabWrapper: {
flexDirection: 'row',
justifyContent: 'center',
alignItems: 'center',
height: 50,
},
tabInnerWrapper: {
marginRight: 12,
marginLeft: 12,
justifyContent: 'center',
alignItems: 'center',
},
textStyle: {
fontSize: 12,
color: '#62666b',
},
focusTextStyle: {
fontSize: 12,
color: '#acafb1',
},
};
const {body, tabWrapper, tabInnerWrapper, textStyle, focusTextStyle} = styles;
const focusIconColor = '#acafb1';
const iconColor = '#62666b';
const IconNames = ['ios-compass-outline', 'ios-cut-outline', 'ios-chatboxes-outline'];
const IconNamesFocus = ['ios-compass', 'ios-cut', 'ios-chatboxes'];
const CustomTabBar = ({ navigation: { state, navigate }}) => {
const { routes } = state;
return (
<View style={body}>
<View style={tabWrapper}>
{routes && routes.map((route, index) => {
const focused = index === state.index;
return (
<TouchableOpacity
key={route.key}
onPress={() => navigate(route.routeName)}
style={tabInnerWrapper}
>
<Icon
name={focused ? IconNamesFocus[index] : IconNames[index]}
size={25}
color={focused ? focusIconColor : iconColor}
/>
<Text style={focused ? focusTextStyle : textStyle}>
{route.routeName}
</Text>
</TouchableOpacity>
);
})}
</View>
</View>
);
};
`
+0
ty!..這就是我一直在尋找:) –
+0
另外,我在哪裏放置Layoutanimation線動畫焦點圖標? –
相關問題
- 1. 自定義Backstage視圖選項卡像標準選項卡FileNew
- 2. 更改自定義選項卡欄中每個選項卡的背景顏色
- 3. 如何在我的頁面中添加自定義選項卡?
- 4. 如何將自定義選項卡添加到自定義模塊中的cms頁面選項卡面板magento
- 5. 如何清除舊選項卡並在選項卡上添加新選項卡
- 6. jquery-ui選項卡 - 添加選項卡
- 7. 在JTabbedpane選項卡上添加圖標
- 8. 如何添加和刪除C#中的「自定義」選項卡
- 9. LWUIT:選項卡 - 如何標記當前選定的選項卡
- 10. Jquery自定義選項卡
- 11. PySide自定義選項卡
- 12. 在窗體上移動自定義選項卡/子選項卡
- 13. Android選項卡,如何顯示選定選項卡的圖像
- 14. 添加圖片的選項卡標籤
- 15. 自定義選項卡形狀的ASP.NET選項卡控件
- 16. 如何編輯GVim中每個選項卡的選項卡標籤?
- 17. 自定義TabWidget Android選項卡指標
- 18. 如何自定義ActionBar選項卡
- 19. 如何獲得自定義選項卡
- 20. 在Android ActionBar選項卡的選項卡中添加FragmentActivity。
- 21. 自定義選項卡欄圖標選中時未「填充」
- 22. 自定義選項卡組加速器
- 23. 所有選項卡添加標題選項卡控件
- 24. 如何在Drupal中添加選項卡?
- 25. 在SpringBoot Admin Server上添加一個自定義選項卡
- 26. react-native-router-flux選項卡如何更改選定選項卡的圖標?
- 27. 自定義選項卡:通過styles.xml設計選項卡
- 28. Android - 導航選項卡 - 刷卡選項卡(固定選項卡)
- 29. jquery選項卡,爲每個選項卡重新加載頁面
- 30. 如何將自定義選項卡添加到Team Web Access
您是否嘗試過使用代替在CustomTabBar? –
@MayurBhangale然後它會顯示每個標籤相同的圖像。 –
檢查此:https://reactnavigation.org/docs/navigators/tab –