Question

Instead of doing self.view = view; like I am currently I want to present this view with animation. It is not an entire view controller but just a view, I am just replacing the current view with this view on a button click.

Is there anyway to do this animated?

Thanks in advance.

Was it helpful?

Solution

Try something like:

UIView *newView = ...;
// new view is added as a subview somewhere

newView.alpha = 0;

[UIView animateWithDuration:1
                 animations:^{
    newView.alpha = 1;
}];

Which will fade the view in. You could also look at animateWithDuration:delay:options:animations:completion: which provides other animation options. Or transitionFromView:toView:duration:options:completion:.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top