Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mgrebenets/mbpopoverbackgroundview
iOS: Custom Popover Background View
https://github.com/mgrebenets/mbpopoverbackgroundview
Last synced: about 2 months ago
JSON representation
iOS: Custom Popover Background View
- Host: GitHub
- URL: https://github.com/mgrebenets/mbpopoverbackgroundview
- Owner: mgrebenets
- License: mit
- Created: 2012-02-10T05:05:45.000Z (almost 13 years ago)
- Default Branch: master
- Last Pushed: 2013-06-19T12:51:25.000Z (over 11 years ago)
- Last Synced: 2024-10-19T08:27:44.574Z (2 months ago)
- Language: Objective-C
- Homepage:
- Size: 206 KB
- Stars: 25
- Watchers: 3
- Forks: 3
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# MBPopoverBackgroundView
Custom `UIPopoverController` background view for iOS.
Implements custom subclass of `UIPopoverBackgroundView` as described in iOS Developer documentation* [UIPopoverController Class Reference](https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIPopoverController_class/Reference/Reference.html#//apple_ref/occ/cl/UIPopoverController)
* [UIPopoverBackgroundView Class Reference](https://developer.apple.com/library/ios/#documentation/UIKit/Reference/UIPopoverBackgroundView_class/Reference/Reference.html#//apple_ref/occ/cl/UIPopoverBackgroundView)
* [View Controller Catalog for iOS - Popover](https://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/ViewControllerCatalog/Chapters/Popovers.html)
* [iPad-Specific Controllers](https://developer.apple.com/library/ios/#documentation/WindowsViews/Conceptual/ViewControllerPGforiOSLegacy/iPadControllers/iPadControllers.html)## Examples
Call `initialize` method of `MBPopoverViewBackground` class to perform required initialization for this class and all of it's subclasses. Call this method once when the app starts.
Set your custom arrow and background images by calling `setArrowImageName:` and `setBackgroundImageName:`.
Set your custom cap insets for stretching background image with `setBackgroundImageCapInsets:`.
Define insets from the edges of content view to the edges of background view using `setContentViewInsets:` method.
// Blue popover
@interface MBPopoverBackgroundViewBlue : MBPopoverBackgroundView
@end// When the app launches
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{// Initialize
[MBPopoverBackgroundView initialize];// Red popover with arrow
[MBPopoverBackgroundView setArrowImageName:@"popover-arrow-red.png"];
[MBPopoverBackgroundView setBackgroundImageName:@"popover-background-red.png"];
[MBPopoverBackgroundView setBackgroundImageCapInsets:UIEdgeInsetsMake(12, 12, 12, 12)];
[MBPopoverBackgroundView setContentViewInsets:UIEdgeInsetsMake(10, 10, 10, 10)];// Blue popover with custom call-out instead of arrow
[MBPopoverBackgroundViewBlue setArrowImageName:@"popover-callout-dotted-blue.png"];
[MBPopoverBackgroundViewBlue setBackgroundImageName:@"popover-background-blue.png"];
[MBPopoverBackgroundViewBlue setBackgroundImageCapInsets:UIEdgeInsetsMake(15, 15, 15, 15)];
[MBPopoverBackgroundViewBlue setContentViewInsets:UIEdgeInsetsMake(20, 20, 20, 20)];// ***
}// When creating popover in the app
{
UIPopoverController *popoverCtl = ...;
popoverCtl.popoverBackgroundViewClass = [MBPopoverBackgroundView class]; // red
popoverCtl.popoverBackgroundViewClass = [MBPopoverBackgroundViewBlue class]; // or blue
// ***
}## Screenshots
![Red Popover](screenshots/red_popover.jpg)## Video
[Video demonstration on YouTube](http://www.youtube.com/watch?feature=player_embedded&v=Kf_CavsYAD0)