PencilKitCanvas cannot becomeFirstResponder in SwiftUI

I have done the same thing in SwiftUI using UIViewRepresentable, but toolPicker doesn't show so I checked isFirstResponder property and I found that it was still false after I called canvas.becomeFirstResponder().

Check this out:

struct NoteCanvasView: UIViewRepresentable {

    func makeUIView(context: Context) -> PKCanvasView {

        let canvas = PKCanvasView()

        canvas.drawingPolicy = .anyInput

        canvas.delegate = context.coordinator.self

        

        let toolPicker = PKToolPicker()

        toolPicker.setVisible(true, forFirstResponder: canvas)

        toolPicker.addObserver(canvas)

        print(canvas.canBecomeFirstResponder)

        canvas.becomeFirstResponder()

        print(canvas.isFirstResponder)

        return canvas

    }

    

    func updateUIView(_ canvas: PKCanvasView, context: Context) {

        canvas.becomeFirstResponder()

    }

    

    func makeCoordinator() -> Coordinator {

        Coordinator(self)

    }

    

    class Coordinator: NSObject {

        var parent: NoteCanvasView

        init(_ parent: NoteCanvasView) {

            self.parent = parent

        }

    }

}

I found canvas.canBecomeFirstResponder returns true and canvas.isFirstResponder always returns false.

Is this a bug in current version of SwiftUI??

PencilKitCanvas cannot becomeFirstResponder in SwiftUI
 
 
Q