动画后更改ViewController

时间:2018-12-12 11:52:47

标签: ios swift segue

我已经为应用程序的第一个屏幕创建了此动画(我没有使用Launchscreen),但是当动画结束时,我不知道如何传递给下一个视图控制器。我对搜索感到厌倦,但一无所获:/

import UIKit
class ViewController: UIViewController {
    @IBOutlet weak var logoLSMini: UIImageView!
    @IBOutlet weak var logoLSMini2: UIImageView!
    @IBOutlet weak var logoLS: UIImageView!

    override func viewWillAppear(_ animated: Bool) {
        super.viewWillAppear(animated)
        self.logoLSMini.alpha = 0.0
        self.logoLSMini2.alpha = 0.0
        self.logoLS.alpha = 0.0
        self.logoLS.frame.origin.y = +100


    }

    override func viewDidAppear(_ animated: Bool) {
        super.viewDidAppear(animated)
        UIView.animate(withDuration: 5, delay: 0.0, options: .curveEaseOut , animations: {
            //FIRST EFFECT

            self.logoLSMini.alpha = 1.0
            self.logoLSMini.transform = CGAffineTransform(rotationAngle: 360)
            self.logoLSMini.transform = CGAffineTransform(scaleX: 100, y: 100)
            self.logoLS.alpha = 1.0

        }, completion: nil)
    }

    override func viewDidLoad() {
        super.viewDidLoad()
    }
}

2 个答案:

答案 0 :(得分:3)

您只需要在completion的{​​{1}}中执行segue。只需确保将添加到情节提要中的序列中的任何标识符替换为UIView.animate

yourSegue

答案 1 :(得分:1)

尝试将移动viewController的代码放入completionHandler

UIView.animate(withDuration: 5, delay: 0.0, options: .curveEaseOut, animations: {
    .....
}, completion: { (finished) in
    if finished {

        //Move to your next controller
        DispatchQueue.main.async {
            //Your code
        }
    }
})