Different transition for each view in same view controller swift?

37 views Asked by At

Hi guys ı am stucked when ı try to present view controller . I split my main view to two views my desire is top view comes with .crossdisolve transition and below view comes with fade in transition . But these are in same view controller.Is this possible .

1

There are 1 answers

0
Oguzhan Karakus On

This is how you try to do it in its simplest form.

You can adapt it with this or if you share a few code examples, I can be more helpful.

class ViewController: UIViewController {
    
    @IBOutlet private weak var topView: UIView!
    @IBOutlet private weak var bottomView: UIView!

    override func viewDidLoad() {
        super.viewDidLoad()
        
        topView.backgroundColor = .red
        
        bottomView.alpha = 0.0
        
        UIView.animate(withDuration: 1, delay: 0, options: .transitionCrossDissolve) { [weak self] in
            self?.topView.backgroundColor = .blue
        }
        
        UIView.animate(withDuration: 1) { [weak self] in
            self?.bottomView.alpha = 1.0
        }

    }
}