Slide UIView with kCATransitionPush

I am trying to open a UIView a quarter of a page to open another view below it (to display the options), and then go down to cover these options. I searched SO ruthlessly but cannot find what I am looking for. I do not want to use modalview, because I want to keep the top view on the screen. In the code below, I have the kind of work, the top level of the slides, but then completely disappears (disappears).

Any help is much appreciated!

Thank.

HomeOptionsViewController *homeOptionsViewController  = [[HomeOptionsViewController  alloc] 
                      initWithNibName:@"HomeOptionsViewController" 
                      bundle:nil];
// get the view that currently showing
UIView *currentView = self.view;
// get the the underlying UIWindow, or the view containing the current view
UIView *theWindow = [currentView superview];

UIView *newView = homeOptionsViewController.view; 
//newView.frame = CGRectMake(0,300, 320,140);
    newView.frame = CGRectMake(0,-10, 320,140);
// remove the current view and replace with myView1
//---[currentView removeFromSuperview];
[theWindow addSubview:newView];

theWindow.frame = CGRectMake(0,-110,320,200);

newView.frame = theWindow.bounds;
// set up an animation for the transition between the views

CATransition *animation = [CATransition animation];
[animation setDuration:0.5];
[animation setType:kCATransitionPush];
[animation setSubtype:kCATransitionFromTop];
[animation setTimingFunction:[CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut]];
//[theWindow setFrame:CGRectMake(0,200,320,300)];
[[theWindow layer] addAnimation:animation forKey:@"SwitchToView1"];
+5
source share
1 answer

, UIView? CAT- , .

- ? , , . .

newView.frame = CGRectMake(0,416,320,140);
[theWindow addSubview:newView];
[UIView beginAnimations:@"SwitchToView1" context:nil];
[UIView setAnimationDuration:0.5];
theWindow.frame = CGRectOffset(theWindow.frame, 0, -140);
newView.frame = CGRectOffset(newView.frame, 0, -140);
[UIView commitAnimations];
+3

All Articles