You can also animate transitions using UIView's transition(from:to:duration:options:completion:) or transition(with:duration:options:animations:completion:) functions. Links to the Apple documentation to these functions are here and here.
Please keep in mind that Apple is discouraging use of these animation techniques as of iOS 13 and recommending to use UIViewPropertyAnimator class functions instead.
Let me give an example of the usage in Swift:
let containerView = UIView()
let transitionFromView = UIView()
containerView.addSubview(transitionFromView)
//add your layout constraints to the transitionFromView within the containerView
let transitionToView = UIView()
containerView.addSubview(transitionToView)
//add your layout constraints to the transitionToView within the containerView
...
func performTransition1() {
//since both transitionFromView and transitionToView have already been added
//to their parent's subviews, we can use showHideTransitionViews animation option
//in this example I am using transitionCrossDissolve animation; however,
//there are other options that can be used instead such as
//transitionFlipFromRight
UIView.transition(from: transitionFromView,
to: transitionToView,
duration: 0.5,
options: [.showHideTransitionViews, .transitionCrossDissolve],
completion: nil)
}
ps: full list of animation options can be found here