I would like to hide the Undo and Redo bar button items in the Keyboard's Shortcut bar (available in iOS 9+). I read here that you can hide them by using this code. Unfortunately this hides also the Cut and Copy items which rather I prefer to keep.
let item : UITextInputAssistantItem = yourTextView.inputAssistantItem
item.leadingBarButtonGroups = [] // this hides Undo, Redo and also Cut, Copy and Paste