-1

I am trying to create a curved path wrapped in a shape in order to attach to a tab bar but I’m having trouble get the desired look. enter image description here Here’s the look I am going for. Any ideas on how to create this shape?

Liam
  • 41
  • 3

1 Answers1

0

I was able to answer my own question by using the a custom path and attaching it to the tab bar.

struct Arc: Shape {

    var height: CGFloat = 20
    var length: CGFloat = 80
    var startX: CGFloat = 0

    func path(in rect: CGRect) -> Path {
        var path = Path()
        let midPoint: CGFloat = (startX + length) / 2
        let apex1: CGFloat = (startX + midPoint) / 2
        let apex2: CGFloat = (midPoint + length) / 2

        path.move(to: CGPoint(x: startX, y: height))

        path.addCurve(to: CGPoint(x: midPoint, y: 0), control1: CGPoint(x: apex1, y:
            height), control2: CGPoint(x: apex1, y: 0))

        path.addCurve(to: CGPoint(x: length, y: height), control1: CGPoint(x: apex2, y: 0), control2: CGPoint(x: apex2, y: height))


        return path
    }
}
Liam
  • 41
  • 3