Creating a wave shape using the Shape protocol and Path function
For the wave shape, it’s easy – we just need to make three straight lines and one curved line and join them together. Think of it as a rectangle, with the top line of the rectangle being the curvy wave part (skip to Figure 10.4 to see what I mean).
Before we start adding the wave code, let’s first modify the Previews
struct so that we can see the results of each line of code we add. Modify the code so it looks like the following:
struct WaveView_Previews: PreviewProvider { static var previews: some View { Group { WaveView(yOffset: 0.7) .stroke(Color.blue, lineWidth: 3) .frame(height: 250) ...