Andrew
Andrew

Reputation: 7883

Handle end of custom transition when not animated?

I'm using a custom transition in my app.

I have an animateTransition method, which gives me a UIViewControllerContextTransitioning, and allows me to set the containerView.backgroundColor to UIColor.blackColor() in the completion of the UIView.animate.. block.

The problem comes if I call presentViewController: with animated set to false. No animation means the animateTransition method is never called, and so my background isn't turned to black as intended.

I was wondering how else I'd be able to set the container view's background color to black, without animating the custom transition in.

By the way, not animating it in doesn't mean that I wouldn't be animating it out. And removing it on the animate in doesn't help matters, as it still doesn't give me an opportunity to make the containerView black.

Upvotes: 0

Views: 82

Answers (1)

Aleksi Sjöberg
Aleksi Sjöberg

Reputation: 1474

You can do it inside the View Controllers viewDidLoad -method, like this:

override func viewDidLoad() {
    super.viewDidLoad()
    self.view.backgroundColor = UIColor.blackColor()
}

Upvotes: 1

Related Questions