javascript - 在 React JS 和 iOS 中,底部标签被底部标签导航器截断
问题描述
我有一个使用 expo 创建的应用程序并做出原生反应。它通过对数组的映射创建卡片。在浏览器上运行时一切正常。当我在 iOS 上运行时,它的底部卡片部分位于底部选项卡导航器下方。我想要底部选项卡导航器上方的一些填充,但不知道该怎么做。起作用的一件事是将 paddingBottom 添加到内联样式中,但这会在卡片之间产生很大的间隙,我只希望最底部的卡片具有该填充。
正在映射的卡片代码:
let completedUserImages = "";
if (linksUpdated) {
completedUserImages = user.completedImageLinks.map((image) => (
<Card
elevation={5}
style={{
padding: 5,
margin: 10,
borderRadius: 15,
}}
key={image.metadata.name}
>
<Card.Title
title={image.metadata.name}
titleStyle={{ textAlign: "center" }}
/>
<Image
style={{ height: 400, resizeMode: "contain" }}
source={{ uri: image.link }}
/>
<Card.Content>
<ImageForm
key={image.metadata.id}
name={image.metadata.name.split("_").pop()}
fromPath={image.metadata.path_lower}
/>
</Card.Content>
</Card>
));
} else {
completedUserImages = <Skeleton />;
}
return (
<ScrollView
style={styles.container}
refreshControl={
<RefreshControl refreshing={refreshing} onRefresh={onRefresh} />
}
>
<Text style={styles.text}>Review Images</Text>
{completedUserImages}
</ScrollView>
);
}
const styles = StyleSheet.create({
container: {
flex: 1,
paddingTop: 48,
backgroundColor: "#cf9d13",
},
text: {
fontSize: 24,
textAlign: "center",
color: "#ffffff",
backgroundColor: "#cf9d13",
},
});
底部标签的代码
export default function MainStackScreens() {
const MainStack = createBottomTabNavigator();
const tabBarOptions = {
showLabel: false,
style: {
backgroundColor: "#cf9d13",
paddingBottom: 12,
},
};
const screenOptions = ({ route }) => ({
tabBarIcon: ({ focused }) => {
let iconName = "home";
switch (route.name) {
case "Home":
iconName = "images-sharp";
break;
case "Review":
iconName = "arrow-redo-sharp";
break;
case "Notifications":
iconName = "notifications";
break;
case "Profile":
iconName = "person";
break;
case "Post":
iconName = "add-circle";
break;
default:
iconName = "images-sharp";
}
return (
<Icon
name={iconName}
size={24}
color={focused ? "#ffffff" : "#666666"}
/>
);
},
});
return (
<MainStack.Navigator
tabBarOptions={tabBarOptions}
screenOptions={screenOptions}
>
<MainStack.Screen name="Home" component={HomeScreen} />
<MainStack.Screen name="Review" component={ReviewScreen} />
<MainStack.Screen name="Post" component={PostScreen} />
{/* <MainStack.Screen name="Notifications" component={NotificationsScreen} /> */}
<MainStack.Screen name="Profile" component={ProfileScreen} />
</MainStack.Navigator>
);
}
解决方案
推荐阅读
- dictionary - 在字典存在或不存在的情况下播放 ansible 任务
- python - 如何检测通过opencv python中的模板匹配提取的形状周围的轮廓?
- javascript - 可以在不同时间间隔触发的 NodeJS OOP 计数器
- angular - 将数据转换为 csv 文件并将其存储在 angular 7 中的 azure blob 存储中
- ubuntu - 如何使用 pm2 自动重启脚本?
- wordpress - 从自动缩放的图像 Wordpress 中删除“-scaled”
- r - R从df中删除行时,如果条件不能满足,which()删除所有行
- java - 在 JNA 中映射 COM 接口方法
- r - 循环提取特定的栅格/空间点对
- php - PHP:在类中处理私有和公共函数