labelStyle 按以下方式应用会导致顶部出现间隙:
labelStyle
const tabNavigator = createBottomTabNavigator( { HomeStack, RecipesStack, FavoriteStack, ProductsStack, }, { tabBarOptions: { activeBackgroundColor: '#8BC540', inactiveBackgroundColor: '#349746', activeTintColor: '#F5F4F4', // tab text color inactiveTintColor: '#F5F4F4', // This messes up the bottom bar labelStyle: { marginTop: 15, marginBottom: 4, }, }, } );
下面是它的外观:
据我所知,这是因为我用 SafeAreaView
SafeAreaView
一旦我搬走 安全区域视图 ,下面的样式有效:
安全区域视图
tabBarOptions: { activeBackgroundColor: '#8BC540', inactiveBackgroundColor: '#349746', activeTintColor: '#F5F4F4', // tab text color inactiveTintColor: '#F5F4F4', tabStyle: { paddingTop: 10, }, style: { height: 58, }, labelPosition: 'below-icon', labelStyle: { marginTop: 5, marginBottom: 4, }, }