baileyseymour baileyseymour - 1 year ago 152
Objective-C Question

Fade UIView and Switch UIView

This is how I switch from one UIView to another UIView:

self.view = MyView;

How would I fade out a view to my

Answer Source

You can use UIView's build in transition code to cross dissolve between them.

[UIView transitionFromView:self.view toView:MySecondView duration:0.25 options:UIViewAnimationOptionTransitionCrossDissolve completion:^(BOOL finished) {
    // What to do when its finished.

You can also use the regular animation options with something like this. I haven't tested this code as I'm not in front of Xcode but I use it all the time for labels and things without default animations.

[UIView animateWithDuration:0.25 animations:^{
    [self.view setAlpha:0.0];
    self.view = mySecondView;
    [self.view setAlpha:1.0];
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download