Latest 1.0.6
Homepage https://github.com/dvkch/SYPopover
License Custom
Platforms ios 8.0, requires ARC
Dependencies SYKit
Authors

SYPopoverController

UIPresentationController subclass to show a UIViewController centered on-screen, with the desired preferredContentSize.

PS: sorry, not the best name, but SYPopupController was already taken.

Sample code

// 1. The controllers your want to present in the popover
UINavigationController *navController = [[UINavigationController alloc] init];
UIViewController *viewController = [[UIViewController alloc] init];
[navController setViewControllers:@[viewController]];

// 2. Prepare the navigationController to use SYPopoverController
[navController setModalPresentationStyle:UIModalPresentationCustom];
[navController setTransitioningDelegate:[SYPopoverTransitioningDelegate shared]];

// 3. Present
[self presentViewController:navController animated:YES completion:nil];

// (Optional) 4. Access the popoverController to use the background you wish
// Here we use a semi-transparent white color
SYPopoverController *popoverController = (SYPopoverController *)navController.presentationController;
[popoverController.backgroundView setBackgroundColor:[UIColor colorWithWhite:1. alpha:0.6]];

// Alternative to 2+3: use the helper method
[self sy_presentPopover:navController animated:YES completion:nil];

Customizations

Background

By default there is no background. You have two options to change this behaviour:

  • Implement popoverControllerBackgroundColor: from SYPopoverContentViewDelegate in presented view controllers

  • Access the background view using the following code, and change its background color or add a subview

     [(SYPopoverController *)myViewController.presentationController backgroundView]
Dismiss

By default when the user taps the background of the popoverController it is dismissed. You can override this behaviour by conforming to SYPopoverContentViewDelegate and implementing popoverControllerShouldDismissOnBackgroundTap:

License

Use it as you like in every project you want, redistribute with mentions of my name and don’t blame me if it breaks :)

— dvkch

Latest podspec

{
    "name": "SYPopover",
    "platforms": {
        "ios": "8.0"
    },
    "version": "1.0.6",
    "license": "Custom",
    "summary": "Popover created with simple navigation controller and view controller subclasses",
    "homepage": "https://github.com/dvkch/SYPopover",
    "authors": {
        "Stan Chevallier": "[email protected]"
    },
    "source": {
        "git": "https://github.com/dvkch/SYPopoverController.git",
        "tag": "1.0.6"
    },
    "source_files": "*.{h,m}",
    "requires_arc": true,
    "xcconfig": {
        "CLANG_MODULES_AUTOLINK": "YES"
    },
    "dependencies": {
        "SYKit": [
            ">= 0.0.12"
        ]
    },
    "deprecated_in_favor_of": "SYPopoverController"
}

Pin It on Pinterest

Share This