Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- + (void)setAnimationTransition:(UIViewAnimationTransition)transition forView:(UIView *)view cache:(BOOL)cache;
- UIViewAnimationTransitionFlipFromLeft,
- UIViewAnimationTransitionFlipFromRight,
- CGContextRef context = UIGraphicsGetCurrentContext();
- [UIView beginAnimations:nil context:context];
- [UIView setAnimationTransition:UIViewAnimationTransitionFlipFromLeft forView:yourContainerView cache:YES];
- [yourContainerView exchangeSubviewAtIndex:0 withSubviewAtIndex:1];
- [UIView commitAnimations];
- - (void)loadFlipsideViewController {
- FlipsideViewController *viewController = [[FlipsideViewController alloc] initWithNibName:@"FlipsideView" bundle:nil];
- self.flipsideViewController = viewController;
- [viewController release];
- // Set up the navigation bar
- UINavigationBar *aNavigationBar = [[UINavigationBar alloc] initWithFrame:CGRectMake(0.0, 0.0, 320.0, 44.0)];
- aNavigationBar.barStyle = UIBarStyleBlackOpaque;
- self.flipsideNavigationBar = aNavigationBar;
- [aNavigationBar release];
- UIBarButtonItem *buttonItem = [[UIBarButtonItem alloc] initWithBarButtonSystemItem:UIBarButtonSystemItemDone target:self action:@selector(toggleView)];
- UINavigationItem *navigationItem = [[UINavigationItem alloc] initWithTitle:@"Test123"];
- navigationItem.rightBarButtonItem = buttonItem;
- [flipsideNavigationBar pushNavigationItem:navigationItem animated:NO];
- [navigationItem release];
- [buttonItem release];
- }
- - (IBAction)toggleView {
- /*
- This method is called when the info or Done button is pressed.
- It flips the displayed view from the main view to the flipside view and vice-versa.
- */
- if (flipsideViewController == nil) {
- [self loadFlipsideViewController];
- }
- UIView *mainView = mainViewController.view;
- UIView *flipsideView = flipsideViewController.view;
- [UIView beginAnimations:nil context:NULL];
- [UIView setAnimationDuration:1];
- [UIView setAnimationTransition:([mainView superview] ? UIViewAnimationTransitionFlipFromRight : UIViewAnimationTransitionFlipFromLeft) forView:self.view cache:YES];
- if ([mainView superview] != nil) {
- [flipsideViewController viewWillAppear:YES];
- [mainViewController viewWillDisappear:YES];
- [mainView removeFromSuperview];
- [infoButton removeFromSuperview];
- [self.view addSubview:flipsideView];
- [self.view insertSubview:flipsideNavigationBar aboveSubview:flipsideView];
- [mainViewController viewDidDisappear:YES];
- [flipsideViewController viewDidAppear:YES];
- } else {
- [mainViewController viewWillAppear:YES];
- [flipsideViewController viewWillDisappear:YES];
- [flipsideView removeFromSuperview];
- [flipsideNavigationBar removeFromSuperview];
- [self.view addSubview:mainView];
- [self.view insertSubview:infoButton aboveSubview:mainViewController.view];
- [flipsideViewController viewDidDisappear:YES];
- [mainViewController viewDidAppear:YES];
- }
- [UIView commitAnimations];
- }
Add Comment
Please, Sign In to add comment