问题
I am using present view controller for displaying a new view controller from left.. the code i used is..
UIViewController *controller;
UINavigationController *navi;
UIView *popmenu = [[UIView alloc] initWithFrame:CGRectMake(0, 0, 200, 300)];
popmenu.backgroundColor = [UIColor yellowColor];
controller.view = popmenu;
controller.view.superview.backgroundColor = [UIColor clearColor];
navi = [[UINavigationController alloc]initWithRootViewController:controller];
navi.view.superview.backgroundColor = [UIColor clearColor];
CATransition *transition = [CATransition animation];
transition.duration = 0.4;
transition.timingFunction = [CAMediaTimingFunction functionWithName:kCAMediaTimingFunctionEaseInEaseOut];
transition.type = kCATransitionPush;
transition.subtype = kCATransitionFromLeft;
[self.view.window.layer addAnimation:transition forKey:nil];
[self presentViewController:navi animated:NO completion:nil];
navi.view.superview.frame = CGRectMake(0, 0, 200, 540);
the output i got is..

回答1:
You can make the presented view controller transparent but the presenting view controller will always disappear (i.e. the background becomes black) if you use the presentViewController:animated:completion: method without specifying a UIViewControllerTransitioningDelegate for the presented controller.
Here's a good tutorial that explains how to make custom transitions on iOS 7 http://www.doubleencore.com/2013/09/ios-7-custom-transitions/
And here's my experiment of it: https://github.com/Jafared/CustomTransitionTests
Note that it'll work only on iOS 7
回答2:
I am using this solution.. instead of creating another controller and other stuff..this seem pretty easy.
[UIView animateWithDuration:1.0 animations:^{
//Move frame or transform view
popmenu.frame = CGRectMake(0,0,200,570);
table.frame = CGRectMake(200, 0, 120, 570);
}];
回答3:
I used the following approach on iOS7.
It adds the view above the navigation-controller, in the correct orientation, responds to orientation-changes of the new and underlying view-controller and the background is finally transparent.
UIView *rootView = [[[[self view] window] rootViewController] view];
UIView *myView = [[self myViewController] view];
[myView setFrame:[rootView bounds]];
[myView setTranslatesAutoresizingMaskIntoConstraints:YES];
[myView setAutoresizingMask:UIViewAutoresizingFlexibleWidth | UIViewAutoresizingFlexibleHeight];
[rootView addSubview:myView];
This means you have to implement your own animation though.
来源:https://stackoverflow.com/questions/21380735/how-to-make-the-modal-view-controller-transparent