import SwiftUI // MARK: - SwiftUI 背景重绘(方形版本) struct CardBlindBackground: View { var body: some View { GeometryReader { geo in let w = geo.size.width let h = geo.size.height ZStack { // 主背景卡片(方形) ScoopRoundedRect(cornerRadius: 20, scoopDepth: 20, scoopHalfWidth: 90, scoopCenterX: 0.5, convexDown: true, flatHalfWidth: 60) .fill(Theme.Colors.primary) .shadow(color: .black.opacity(0.08), radius: 12, y: 6) .padding() Rectangle() .fill( LinearGradient( colors: [Color(hex: "FFFFFF"), Color(hex: "FFEFB2")], startPoint: .topTrailing, endPoint: .bottomLeading ) ) .frame(width: w - 100 , height: h - 130) .cornerRadius(20) .padding(.top, Theme.Spacing.lg) // var view = UIView() // view.frame = CGRect(x: 0, y: 0, width: 320, height: 464) // let layer0 = CAGradientLayer() // layer0.colors = [ // UIColor(red: 1, green: 1, blue: 1, alpha: 1).cgColor, // UIColor(red: 1, green: 0.937, blue: 0.698, alpha: 1).cgColor // ] // layer0.locations = [0, 1] // layer0.startPoint = CGPoint(x: 0.25, y: 0.5) // layer0.endPoint = CGPoint(x: 0.75, y: 0.5) // layer0.transform = CATransform3DMakeAffineTransform(CGAffineTransform(a: -1.13, b: 1.07, c: -1.08, d: -0.54, tx: 1.65, ty: 0.24)) // layer0.bounds = view.bounds.insetBy(dx: -0.5*view.bounds.size.width, dy: -0.5*view.bounds.size.height) // layer0.position = view.center // view.layer.addSublayer(layer0) // view.layer.cornerRadius = 18 // 左上光斑 // Circle() // .fill(Color.themePrimary.opacity(0.18)) // .blur(radius: 40) // .frame(width: min(w, h) * 0.35, height: min(w, h) * 0.35) // .position(x: w * 0.25, y: h * 0.25) // 右下光斑 // Circle() // .fill(Color.orange.opacity(0.14)) // .blur(radius: 50) // .frame(width: min(w, h) * 0.40, height: min(w, h) * 0.40) // .position(x: w * 0.75, y: h * 0.75) // 中央高光描边 // RoundedRectangle(cornerRadius: 28) // .stroke(Color.white.opacity(0.35), lineWidth: 1) // .frame(width: w * 0.88, height: h * 0.88) // .position(x: w / 2, y: h / 2) // .blendMode(.overlay) // .opacity(0.7) } } } } // 预览 struct CardBlindBackground_Previews: PreviewProvider { static var previews: some View { CardBlindBackground() .frame(width: 400, height: 600) } }