Dmitry Dmitry - 8 days ago 5
iOS Question

How to make dissolve animation on changing views on iphone?

How to make dissolve animation on changing views in iphone?

Dissolve effect: one view is changing another without any movement.

Thanks a lot for the help!

Answer

The animation you're looking for is:

[UIView animateWithDuration: 1.0
                 animations:^{
                     view1.alpha = 0.0;
                     view2.alpha = 1.0;
                 }];

A more complete solution, using that animation might be:

- (void) replaceView: (UIView *) currentView withView: (UIView *) newView
{
    newView.alpha = 0.0;
    [self.view addSubview: newView];

    [UIView animateWithDuration: 1.0
                     animations:^{
                         currentView.alpha = 0.0;
                         newView.alpha = 1.0;
                     } 
                     completion:^(BOOL finished) {
                         [currentView removeFromSuperview];
                     }];
}
Comments