Code Monkey home page Code Monkey logo

bdbpopupviewcontroller's Introduction

BDBPopupViewController

BDBPopupViewController is a UIViewController category for presenting custom view controllers modally. Using this category makes it trivial to present a modal view controller that defines its own size and allows for a much more customized look and feel than is possible using UIKit's default view controller presentation methods.

Take a look at the included demo project to get started quickly.

Usage

BDBPopupViewController is simple to use because there are only two methods: one for presenting a popup view controller, and one for dismissing it.

- (void)bdb_presentPopupViewController:(UIViewController *)viewController
                         withAnimation:(BDBPopupViewShowAnimationStyle)animation
                            completion:(void (^)(void))completion;

- (void)bdb_dismissPopupViewControllerWithAnimation:(BDBPopupViewHideAnimationStyle)animation
                                         completion:(void (^)(void))completion;

There is also a popupViewController property that allows you to quickly and easily access the currently displayed popup view controller from its parent view controller.

Animation Styles

Animations are split into BDBPopupViewShowAnimationStyle and BDBPopupViewHideAnimationStyle so that you can completely customize how your popup view controller is presented and dismissed.

Default

BDBPopupViewShowAnimationDefault / BDBPopupViewHideAnimationDefault

The default show/hide animation displays a popup view controller in the same default manner as a normal modal view controller. The current view controller is dimmed, and the popup view controller animates in from the bottom of the screen. When dismissed, the popup view controller slides down and the parent view controller becomes active.

Zoom In/Out

BDBPopupViewShowAnimationZoomIn / BDBPopupViewHideAnimationZoomOut

Likely to be the most used animation, the zoom in/out animation does exactly what its name implies: the popup view controller grows from the center of the screen with a little elasticity once it reaches the full size of the view controller (or the screen size on an iPhone). It shrinks back into the center of the screen when dismissed.

Drop-Down / Takeoff

BDBPopupViewShowAnimationDropDown / BDBPopupViewHideAnimationTakeoff

The popup view controller slides in from the top of the screen with a bounce effect and slides back up when dismissed.

Screenshots

iPhone Screenshot iPad Screenshot

Credits

BDBPopupViewController was created by Bradley David Bergeron.

bdbpopupviewcontroller's People

Contributors

bdbergeron avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

bdbpopupviewcontroller's Issues

Presenting over a view controller with non-FullScreen modal presentation style doesn't work

For example, I changed your demo to allow opening another version of the main view controller with FormSheet presentation style, run it on iPod. Hit the nav bar button to open the form view controller and press the button, the popup is opened behind the form view controller's view instead of over top of it.

@interface MainViewController ()
@property (nonatomic, assign, getter=isForm) BOOL form;
@end

@interface FormNavigationViewController : UINavigationController
@end


#pragma mark -
@implementation MainViewController

- (void)viewDidLoad
{
    [super viewDidLoad];

    self.title = NSLocalizedString(@"Popup Demo", nil);

    if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 7.f) {
        self.edgesForExtendedLayout = UIRectEdgeNone;
    }

    if ([[UIDevice currentDevice] userInterfaceIdiom] == UIUserInterfaceIdiomPad) {
        UIBarButtonItem *barButton;
        if (!self.form)
            barButton = [[UIBarButtonItem alloc] initWithTitle:@"Form" style:UIBarButtonItemStylePlain target:self action:@selector(openForm)];
        else
            barButton = [[UIBarButtonItem alloc] initWithTitle:@"Close" style:UIBarButtonItemStylePlain target:self action:@selector(dismissForm)];
        barButton.tintColor = [UIColor whiteColor];
        self.navigationItem.rightBarButtonItem = barButton;
    }
}

- (IBAction)showInfo:(UIButton *)sender
{
    [self bdb_presentPopupViewController:[AboutViewController new]
                           withAnimation:BDBPopupViewShowAnimationZoomIn
                              completion:nil];
}

- (void)openForm
{
    MainViewController *containedViewController = [MainViewController new];
    containedViewController.form = YES;

    UIViewController *form = [[FormNavigationViewController alloc] initWithRootViewController:containedViewController];
    [self presentViewController:form animated:YES completion:nil];
}

- (void)dismissForm
{
    [self dismissViewControllerAnimated:YES completion:nil];
}

@end


#pragma mark -
@implementation FormNavigationViewController

- (UIModalPresentationStyle)modalPresentationStyle
{
    return UIModalPresentationFormSheet;
}

@end```

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.