To detect when user performs the undo/redo gestures:
It is unified through the system, So it is completely free if you are using UndoManager(More details) or NSUndoManager. So if you implement it like the use shakes, it works for the gesture too.
To change the behavior of the gesture (to prevent conflicting with other gestures of the app)
You can change the configuration of it with this variable:
public protocol UIResponder {
var editingInteractionConfiguration: UIEditingInteractionConfiguration
}
it is an enum:
public enum UIEditingInteractionConfiguration {
case `default` // System behavior
case none // Disable
}
So it would be disable like:
override var editingInteractionConfiguration: UIEditingInteractionConfiguration { .none }
Sorce:
WWDC 2019 - Modernizing Your UI for iOS 13 - 37:00
Note that there are bunch of more gestures in iOS 13, for example pinching 3 fingers in will copy the selected text and pinch them out will paste it. All of them connected to the old style actions (for example the classic shake action) alongside with this protocol and you can override it in any responder.
Apple call all of these Editing Gestures and you can see the session here
Note:
Some of the information in that session is not purely true, (for example UIResponder is not a protocol, it's a class actually) as @matt mentioned in the comments. But I have added the source of this answer and you can judge yourself.