Install the Custom Menu | raywenderlich.com


This is a companion discussion topic for the original entry at https://www.raywenderlich.com/6485147-drawing-in-ios-with-swiftui/lessons/16

Hello,

Following this tutorial and found that the tap gesture on the shape modal screen will not respond when clicking inside the shape. It only responds when clicking inside the padding area of the shape. Why is this happening?

Thank you
David

@dahbull - good catch!

That’s because the shape is transparent, because we’re only doing a stroke not a fill.

You can correct this in ShapeGridView.swift. In ShapesGrid, you should have a ForEach in body.

Change the shape.stroke() code to:

ZStack {
  self.finalArray[rowIndex][columnIndex].shape
    .fill(Color.green)
  self.finalArray[rowIndex][columnIndex].shape
    .stroke()
}

(You’d probably use Color.white, but I use weird colors to make sure they are working correctly :grimacing:)

Make sure the frame, padding and gesture are after this code.