gpt4 book ai didi

javascript - React Native - 创建形状的 flex 边缘

转载 作者:行者123 更新时间:2023-12-03 14:30:36 25 4
gpt4 key购买 nike

问题摘要

我正在构建的应用程序有以下底部导航栏,但我不确定如何设计它,因为它比我过去设计的任何样式都更复杂。我在设计白色部分的 flex 顶部边缘以及蓝色/绿色圆圈和白色部分之间的区域时遇到问题。

我从模型中添加了导航栏应该是什么样子,因为其中一个似乎融入其中。绿色/蓝色圆圈和白色部分之间的白色部分上方的黑色背景不应该使用此导航栏进行样式设置,这应该是导航栏后面看到的背景。

任何帮助将不胜感激!

Navigation Bar Example摘要代码

  <View style={styles.container}>
</View>

container: {
width: windowWidth,
height: windowHeight * 0.1020935961,
backgroundColor: "white",
flexDirection: "row",
justifyContent: "space-around",
borderTopLeftRadius: -50,
borderTopRightRadius: -50
}

完整代码

const CustomTabNav = () => (
<View style={styles.container}>
<TouchableOpacity
style={styles.instant}
onPress={() => {
NavigationService.navigate("Home");
}}
>
<Image
style={styles.homeImage}
source={require("~/assets/images/homeIcon.png")}
/>
</TouchableOpacity>
<TouchableOpacity
style={styles.ovalCopy}
onPress={() => NavigationService.navigate("Competitions")}
>
<LinearGradient
start={{ x: 0, y: 1 }}
end={{ x: 1, y: 0 }}
colors={[buttonGradientBlueColor, buttonGradientGreenColor]}
style={styles.linearGradient}
>
<Image
style={styles.plusImage}
source={require("~/assets/images/plus.png")}
/>
</LinearGradient>
</TouchableOpacity>
<TouchableOpacity
style={styles.instant}
onPress={() => NavigationService.navigate("Competitions")}
>
<Image
style={styles.instantImage}
source={require("~/assets/images/competitions.png")}
/>
</TouchableOpacity>
</View>
);

const styles = StyleSheet.create({
container: {
width: windowWidth,
height: windowHeight * 0.1020935961,
backgroundColor: "white",
flexDirection: "row",
justifyContent: "space-around",
borderTopLeftRadius: -50,
borderTopRightRadius: -50
},
homeImage: {
width: windowWidth * 0.05,
height: windowWidth * 0.05
},
instant: {
flexDirection: "column",
// alignSelf: 'center',
justifyContent: "center"
},
instantImage: {
width: windowWidth * 0.05,
height: windowWidth * 0.05
},
ovalCopy: {
width: 64,
height: 64,
},
linearGradient: {
borderRadius: 50, //TODO: make sure this is correct
width: 64,
height: 64,
shadowColor: "#0a0b12cc",
shadowOffset: {
width: 0,
height: -10
},
shadowRadius: 60,
shadowOpacity: 1,
alignItems: 'center',
justifyContent: 'center'
},
plusImage: {
width: windowWidth*0.064,
height: windowWidth*0.064
}
});

最佳答案

嘿,我想你可以用一种困难的方式来做到这一点,比如制作一张背景图片来获得 flex 的白色背景。或者您可以将 2 个“黑灰色” View 叠加在一个白色 View 之上。第一个“黑灰色”可能是具有令人难以置信的大边框半径的一个,第二个是 100% 的圆圈,比 + 按钮稍大。这就是我的意思:

<View style={{ flex: 1, backgroundColor:"white",height: HEIGHT ,width:WIDTH, alignItems: 'center', justifyContent: 'flex-start' }}>
<View style={{ backgroundColor:"black",borderBottomLeftRadius:WIDTH*10,borderBottomRightRadius:WIDTH*10,height: HEIGHT*.6 ,width:WIDTH*2, alignItems: 'center', justifyContent: 'center' }}>
</View>
<View style={{ backgroundColor:"black",borderRadius:60,height: 120 ,width:120, marginTop:-60,alignItems: 'center', justifyContent: 'center' }}>
<View style={{ backgroundColor:"white",borderRadius:40,height: 80 ,width:80 ,alignItems: 'center', justifyContent: 'center' }}>
<Icon name="chevron-left" size={30} />
</View>
</View>
<View style={{ backgroundColor:"transparent",height: 120 ,width:WIDTH, marginTop:-60,flexDirection:"row",padding:20, justifyContent: 'space-between' }}>
<Icon name="chevron-left" size={30} />
<Icon name="chevron-left" size={30} />
</View>
</View>

您将得到的内容的屏幕截图:Screenshoot

关于javascript - React Native - 创建形状的 flex 边缘,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57781643/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com