I have a container view controller and child view controllers (Similar to UITabViewController). When transitioning between the view of one child view controller and another child view controller's view, I am using:
let oldView = // get reference to old view
let newView = // get reference to new view
UIView.transition(from: oldView!, to: newView!, duration: 0.3,
options: .transitionCrossDissolve, completion: nil)
The issue here, is that the resizing of the newView happens after the transition animation completes, which looks unsightly.
This bad behavior is only happening when the new child view controller is loaded for the very first time. It seems that the viewDidLayoutSubviews method is only called after the transition.
How do I get the newView to be resized BEFORE the transition and not after.
Thanks In Advance.
in your ViewController
override func viewWillTransition
so it will be something like this
override func viewWillTransition(to size: CGSize, with coordinator: UIViewControllerTransitionCoordinator) {
let oldView = // get reference to old view
let newView = // get reference to new view
UIView.transition(from: oldView!, to: newView!, duration: 0.3,
options: .transitionCrossDissolve, completion: nil)
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With