import SwiftUI
struct BridgeShape: Shape {
func path(in rect: CGRect) -> Path {
let width = rect.width
let height = rect.height
let bridgeHeight: CGFloat = height * 0.7 // Adjust the height of the bridge
let curveHeight: CGFloat = height * 0.1 // Adjust the height of the curved inset
var path = Path()
// Starting from the top-left corner
path.move(to: CGPoint(x: 0, y: 0))
// Top horizontal line
path.addLine(to: CGPoint(x: width, y: 0))
// Top right curve inset
path.addQuadCurve(to: CGPoint(x: width, y: curveHeight), control: CGPoint(x: width * 0.8, y: curveHeight))
// Top right corner of the bridge
path.addLine(to: CGPoint(x: width, y: bridgeHeight))
// Bottom right corner
path.addLine(to: CGPoint(x: 0, y: bridgeHeight))
// Closing the shape
path.closeSubpath()
return path
}
}
struct ContentView: View {
var body: some View {
ZStack {
Image("BGImage")
.resizable()
.scaledToFill()
.edgesIgnoringSafeArea(.all)
BridgeShape()
.fill(Color.blue)
.frame(height: 250)
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
Replace “BGImage” with the name of your image asset. Adjust the values of bridgeHeight and curveHeight in the BridgeShape struct to modify the appearance of the bridge as needed.




