自定义形状,

This commit is contained in:
2024-01-30 18:06:53 +08:00
parent 5109b242a6
commit 073ff4aa68
11 changed files with 194 additions and 153 deletions

View File

@@ -11,12 +11,6 @@ struct UserView: View {
@State private var showDetail = false
@State private var showUserInfo = false
var grayBackground = Color.gray.opacity(0.2)
init() {
print(UIScreen.main.bounds.width)
}
var body: some View {
ScrollView(.vertical, showsIndicators: false) {
VStack(spacing: 0) {
@@ -64,6 +58,7 @@ struct UserView: View {
}
}
.padding(.horizontal, 24)
.padding(.bottom, 12)
}
var ToVip: some View {
@@ -88,8 +83,7 @@ struct UserView: View {
.frame(height: showDetail ? 64 : 150, alignment: .topLeading)
.background(Color.red.opacity(0.3))
.clipShape(
RoundedRectangle(cornerRadius: 12)
.offset(y: 12)
TopRoundedRectangle(cornerRadius: 8)
)
.padding(.horizontal, 12)
}
@@ -109,25 +103,10 @@ struct UserView: View {
}
.padding(.top, 12)
.background(
Color.white
.overlay(alignment: .top) {
RoundedRectangle(cornerRadius: 12)
.fill(LinearGradient(colors: [Color.orange.opacity(0.3), grayBackground], startPoint: .top, endPoint: .bottom))
.frame(height: 92)
}
TopRoundedRectangle(cornerRadius: 12)
.fill(LinearGradient(colors: [Color.orange, Color.clear], startPoint: .top, endPoint: UnitPoint(x: 0.5, y: 0.2)))
)
.clipped()
// Rectangle()
// .fill(Color.white)
// .frame(height: 12)
// .overlay {
// RoundedRectangle(cornerRadius: 12)
// .fill(grayBackground)
// .frame(height: 24)
// .offset(y: 6)
// }
// .clipped()
}
var Notice: some View {
@@ -167,7 +146,6 @@ struct UserView: View {
.cornerRadius(8)
.padding(.horizontal, 12)
.padding(.vertical, 12)
.background(grayBackground)
}
var OrderShow: some View {
@@ -195,17 +173,16 @@ struct UserView: View {
.resizable()
.frame(width: 24, height: 24)
.foregroundColor(Color.gray)
.overlay(alignment: .topTrailing) {
.overlay(
Circle()
.fill(Color.red.opacity(0.9))
.frame(width: 20, height: 20)
.overlay {
Text("5")
.foregroundColor(Color.white)
.font(.system(size: 12))
}
.overlay(Text("5")
.foregroundColor(Color.white)
.font(.system(size: 12))
)
.offset(x: 12, y: -10)
}
)
Text("待付款")
.font(.system(size: 12))
@@ -221,7 +198,6 @@ struct UserView: View {
.cornerRadius(6)
.padding(.horizontal, 12)
.padding(.bottom, 12)
.background(grayBackground)
}
var Coupons: some View {
@@ -237,17 +213,17 @@ struct UserView: View {
.resizable()
.frame(width: 24, height: 24)
.foregroundColor(Color.gray)
.overlay(alignment: .topTrailing) {
.overlay(
Circle()
.fill(Color.red.opacity(0.9))
.frame(width: 20, height: 20)
.overlay {
.overlay(
Text("5")
.foregroundColor(Color.white)
.font(.system(size: 12))
}
)
.offset(x: 12, y: -10)
}
)
Text("待付款")
.font(.system(size: 12))
.foregroundColor(Color.gray)
@@ -263,7 +239,6 @@ struct UserView: View {
.cornerRadius(6)
.padding(.horizontal, 12)
.padding(.bottom, 12)
.background(grayBackground)
}
let columns = [GridItem(.flexible(), spacing: 12), GridItem(.flexible(), spacing: 12)]
@@ -290,7 +265,6 @@ struct UserView: View {
}
.padding(.horizontal, 12)
.padding(.bottom, 12)
.background(grayBackground)
}
}