当前:
预期:
以下代码仅适用于主页选项卡:
function MyTabs() {
return(
<Tab.Navigator
initialRouteName="Dashboard"
screenOptions={{
tabBarActiveTintColor: "#e91e63",
tabBarStyle: {
paddingTop: 15,
height: 80,
paddingBottom: 15,
borderTopWidth: 0,
paddingHorizontal: 15
}
}}
>
<Tab.Screen
name="Home"
component={HomePage}
options={{
headerShown: false,
tabBarLabelPosition: "beside-icon",
tabBarLabelStyle: {
fontSize: 14,
fontFamily: "Gilroy-Medium",
},
tabBarLabel: ({ focused }) => {
return (
<Text
style={{
fontFamily:"Gilroy-Medium"
fontSize:14
fontWeight:"500"
color:"#D6407A"
}}
>
{focused ? "Home" : ""}
</Text>
);
},
tabBarIcon: ({ focused }) =>
focused ? (
<Image
source={require("./src/assets/Homefill.png")}
style={{ resizeMode: "contain", height: 30, width: 30 }}
/>
) : (
<Image
source={require("./src/assets/Home.png")}
style={{ resizeMode: "contain", height: 30, width: 30 }}
/>
),
}}
/>
</Tab.Navigator>
)
}
我试过将marginLeft
转换为文本,但它的图标也会转到左侧,因此不起作用
我还希望Home
文本旁边的图标,只有当foucused或说,当当前路线是Home
和药丸一样,粉红色的边界
如何使它像上面预期的那样?
1条答案
按热度按时间pzfprimi1#
这会帮你