preferredPencilDoubleTapAction
The action that the user prefers to perform after double-tapping their Apple Pencil, as selected in the Settings app.
Declaration
var preferredPencilDoubleTapAction: PencilPreferredAction { get }Discussion
You can read this value by creating a property with the Environment property wrapper and using it inside the action closure of the onPencilDoubleTap(perform:) view modifier as an indication of what to do after the user double-taps their Apple Pencil:
@Environment(\.preferredPencilDoubleTapAction) private var preferredAction
var body: some View {
MyDrawingCanvas()
.onPencilDoubleTap { value in
switch preferredAction {
...
}
}
}In macOS, this value cannot be changed by users and is always set to switchEraser.