cfischer
cfischer

Reputation: 24902

Animating the transition of a subview in Cocoa Touch

I have a view with a subview in it. The subview will contain other views.

enter image description here

When the user clicks on the menu on the left side, the contents of the subview will be switched: the current view will be removed and a new one will be added.

I want to animate this with an effect similar to UIModalTransitionStyleFlipHorizontal. How can I do this, considering that it wont be a modal form (it wont cover the entire screen)?

Upvotes: 0

Views: 1233

Answers (1)

Jano
Jano

Reputation: 63667

self.currentView.userInteractionEnabled = NO;

[UIView beginAnimations:nil context:nil];
[UIView setAnimationDuration:0.75];
[UIView setAnimationDelegate:self];
[UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:self.currentView cache:YES];
[self.currentView removeFromSuperview];
[self.view addSubview:self.someOtherView];
[UIView commitAnimations];

self.view.userInteractionEnabled = YES;
self.currentView = self.someOtherView;

Upvotes: 1

Related Questions