Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>You can make something like this from scratch pretty easily. The trick is to make your popover view controller have a full screen transparent layer</p> <p>From your main view:</p> <pre><code>self.popoverController = [[PopoverController alloc] initWithNibName:@"PopoverViewController" bundle:nil]; self.popoverController.view.frame = CGRectMake(0, 0, self.view.frame.size.width, self.view.frame.size.height); [self.view addSubview:self.popoverController.view]; // view is the transparent background [self.popoverController viewWillAppear:NO]; </code></pre> <p>Now its just a matter of implementing viewWillAppear if you want transition effects:</p> <pre><code>- (void) viewWillAppear:(BOOL)animated { self.fadeView.alpha = 1.0f; self.view.alpha = 0.0; [self slideIn]; } // Slide in with whatever effects you want your popup to use - (void) slideIn { //set initial location at bottom of view (my popup slid in from the bottom) CGRect frame = self.configView.frame; frame.origin = CGPointMake(0.0, self.view.bounds.size.height); self.configView.frame = frame; [self.view addSubview:self.configView]; //animate to new location, determined by height of the view in the NIB [UIView beginAnimations:@"presentWithSuperview" context:nil]; [UIView setAnimationDuration:0.5]; self.view.alpha = 1.0; // fade in background frame.origin = CGPointMake(0.0, self.view.bounds.size.height -self.configView.bounds.size.height); self.configView.frame = frame; // animate in popup [UIView commitAnimations]; } - (void) slideOut { [UIView beginAnimations:@"removeFromSuperviewWithAnimation" context:nil]; [UIView setAnimationDuration:0.5]; self.view.alpha = 0.0; // Set delegate and selector to remove from superview when animation completes [UIView setAnimationDelegate:self]; [UIView setAnimationDidStopSelector:@selector(animationDidStop:finished:context:)]; // Move this view to bottom of superview (my popup slides back to the bottom when finished) CGRect frame = self.configView.frame; frame.origin = CGPointMake(0.0, self.view.bounds.size.height); self.configView.frame = frame; [UIView commitAnimations]; } // Finally remove the views when you're done animating out. - (void) animationDidStop:(NSString *)animationID finished:(NSNumber *)finished context:(void *)context { if ([animationID isEqualToString:@"removeFromSuperviewWithAnimation"]) { [self.configView removeFromSuperview]; [self.view removeFromSuperview]; } } </code></pre> <p>For bonus points you can make the transparent background a control and have it detect touches for when the popup should go away. I used interface builder to call an action which calls slideOut.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload