@user3429963 is definitely looking in the right direction. Here's what worked for me:
searchBar.becomeFirstResponder()
searchBar.removeLayerAnimationsRecursively()
where removeLayerAnimationsRecursively()
is a function which removes animations from the view layer and its subviews' layers recursively:
extension UIView {
func removeLayerAnimationsRecursively() {
layer.removeAllAnimations()
subviews.forEach { $0.removeLayerAnimationsRecursively() }
}
}