1

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..enter image description here here i can resize the view of the view controller, but how to resize the view controller so that the view present in background i mean the view from which this modal view is called will be visible and i can do operations..like having a button to close this modal view.. thank you..

Alexis
  • 16,629
  • 17
  • 62
  • 107
BalaChandra
  • 632
  • 9
  • 33
  • Is there any navigation from this modal view controller? Or does it just open and then close? – Fogmeister Jan 27 '14 at 12:21
  • @Fogmeister i want to give a table view in that modal view so that the items in main view will be changed basing on the tableview cell chosen – BalaChandra Jan 27 '14 at 12:24
  • first thing you have made your yellow View as the main view of your ViewController using controller.view = popmenu; insteade of this you should use addSubView .Another thing is that You can use splitViewController to fullfil your requirment – Wali Haider Jan 27 '14 at 12:43
  • @walinaqvi when i tried to use split view controller i got this error, UISplitViewController is only supported when running under UIUserInterfaceIdiomPad i think split view is not supported in iPhone – BalaChandra Jan 27 '14 at 12:57
  • http://stackoverflow.com/questions/12741224/ios-modal-viewcontroller-with-transparent-background/22829068#22829068 – Zaraki Apr 03 '14 at 06:03

3 Answers3

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

Alexis
  • 16,629
  • 17
  • 62
  • 107
0

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);
    }];
BalaChandra
  • 632
  • 9
  • 33
0

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.

RhodanV5500
  • 1,087
  • 12
  • 16