Simple way to present custom views as a popup in iOS and tvOS.

Overview

PopupKit

PopupKit is a simple and flexible iOS framework for presenting any custom view as a popup. It includes a variety of options for controlling how your popup appears and behaves.

BuddyBuild

##Installation

###CocoaPods You can install PopupKit easily with Cocoapods

pod 'PopupKit'

###CocoaPods You can install PopupKit easily with Carthage too

github 'rynecheow/PopupKit'

##Usage

To import the framework you can either:

####In Swift,

import PopupKit

####In Objective-C,

@import PopupKit;

or

#import <PopupKit/PopupView.h>

Creating a Popup

Create a popup for displaying a UIView using default animations and behaviors (similar to a UIAlertView):

+ (instancetype)popupWithContentView:(UIView*)contentView;

or similarly in Swift:

convenience init(contentView: UIView)

Or create a popup with custom animations and behaviors. Customizations can also be accessed via properties on the popup instance:

+ (instancetype)popupViewWithContentView:(UIView *)contentView
                                showType:(PopupViewShowType)showType
                             dismissType:(PopupViewDismissType)dismissType
                                maskType:(PopupViewMaskType)maskType
          shouldDismissOnBackgroundTouch:(BOOL)shouldDismissOnBackgroundTouch
             shouldDismissOnContentTouch:(BOOL)shouldDismissOnContentTouch;

or similarly in Swift:

convenience init(contentView: UIView, showType: PopupView.ShowType, dismissType: PopupView.DismissType, maskType: PopupView.MaskType, shouldDismissOnBackgroundTouch: Bool, shouldDismissOnContentTouch: Bool)

Also you must give your contentView a size before showing it (by setting its frame), or it must size itself with AutoLayout.

Showing a Popup

Show popup in middle of screen.

- (void)show;

or similarly in Swift:

func show()

There are two ways to control where your popup is displayed:

  1. Relative layout presets (see PopupView.h for options).
- (void)showWithLayout:(PopupViewLayout)layout;

or similarly in Swift:

func show(with layout: PopupView.Layout)
  1. Explicit center point relative to a view's coordinate system.
- (void)showAtCenter:(CGPoint)center inView:(UIView *)view;

or similarly in Swift:

func show(at center: CGPoint, in view: UIView)

If you want your popup to dismiss automatically (like a toast in Android) you can set an explicit duration:

- (void)showWithDuration:(NSTimeInterval)duration;

or similarly in Swift:

func show(with duration: TimeInterval)

Dismissing a Popup

There are a few ways to dismiss a popup:

If you have a reference to the popup instance, you can send this message to it. If animated, then it will use the animation specified in dismissType. Otherwise it will just disappear:

- (void)dismiss:(BOOL)animated;

or similarly in Swift:

func dismiss(animated: Bool)

If you lost your reference to a popup or you want to make sure no popups are showing, this class method dismisses any and all popups in your app:

+ (void)dismissAllPopups;

or similarly in Swift:

class func dismissAllPopups()

Also you can call this category method from UIView(PopupView) on your contentView, or any of its subviews, to dismiss its parent popup:

- (void)dismissPresentingPopup; // UIView category

or similarly in Swift:

func dismissPresentingPopup()

Customization

Animation used to show your popup:

@property (nonatomic, assign) PopupViewShowType showType;

Animation used to dismiss your popup:

@property (nonatomic, assign) PopupViewDismissType dismissType;

Mask prevents touches to the background from passing through to views below:

@property (nonatomic, assign) PopupViewMaskType maskType;

Popup will automatically dismiss if the background is touched:

@property (nonatomic, assign) BOOL shouldDismissOnBackgroundTouch;

Popup will automatically dismiss if the contentView is touched:

@property (nonatomic, assign) BOOL shouldDismissOnContentTouch;

Override alpha value for dimmed background mask:

@property (nonatomic, assign) CGFloat dimmedMaskAlpha;

Blocks

Use these blocks to synchronize other actions with popup events:

@property (nonatomic, copy) void (^didFinishShowingCompletion)();

@property (nonatomic, copy) void (^willStartDismissingCompletion)();

@property (nonatomic, copy) void (^didFinishDismissingCompletion)();

Example

UIView* contentView = [[UIView alloc] init];
contentView.backgroundColor = [UIColor orangeColor];
contentView.frame = CGRectMake(0.0, 0.0, 100.0, 100.0);

PopupView* popup = [PopupView popupWithContentView:contentView];
[popup show];

Notes

  • Xcode 8.0 / Swift 3.0
  • iOS >= 9.0 (Use as an Embedded Framework)
  • tvOS >= 9.0

TODO

  • Add support for drag-to-dismiss.

##Credits KLCPopup was created by Jeff Mascia and the team at Kullect, where it's used in the Shout Photo Messenger app. Aspects of KLCPopup were inspired by Sam Vermette's SVProgressHUD. PopupKit is a modernised version of KLCPopup ported by Ryne Cheow.

You might also like...
A lightweight library for popup view
A lightweight library for popup view

SHPopup SHPop is lightweight library used for popup view Sample One Sample Two Sample Three Features SHPopup supports a popup inside another popup wit

WKWebView handling popup windows

WKWebViewWithPopUp WKWebView handling pop-up windows Property If there is a pop-up window, use the pop-up window. If there is no pop-up window, use th

A simple way to show toast in SwiftUI.
A simple way to show toast in SwiftUI.

A simple way to show toast in SwiftUI Documentation • Example • Change Log Overview ToastUI provides you a simple way to present toast, head-up displa

Swift wrapper for custom ViewController presentations on iOS
Swift wrapper for custom ViewController presentations on iOS

Presentr is a simple customizable wrapper for the Custom View Controller Presentation API introduced in iOS 8. About iOS let's you modally present any

Simple selection dialog
Simple selection dialog

SelectionDialog Simple selection dialog inspired from ios-custom-alertview Preview Requirements iOS 8.0+ Swift 3 Xcode 8.0 Installation CocoaPods use_

SwiftEntryKit is a presentation library for iOS. It can be used to easily display overlays within your iOS apps.
SwiftEntryKit is a presentation library for iOS. It can be used to easily display overlays within your iOS apps.

SwiftEntryKit 🤗 Donations can be made here. Table of Contents Overview Features Example Project Example Project Installation Presets Playground Requi

Toasts and popups library written with SwiftUI
Toasts and popups library written with SwiftUI

Popup View Toasts and popups library written with SwiftUI We are a development agency building phenomenal apps. Usage Put all your body code into a ZS

LNPopupController is a framework for presenting view controllers as popups of other view controllers, much like the Apple Music and Podcasts apps.
LNPopupController is a framework for presenting view controllers as popups of other view controllers, much like the Apple Music and Podcasts apps.

LNPopupController LNPopupController is a framework for presenting view controllers as popups of other view controllers, much like the Apple Music and

A Swift Popup Module help you popup your custom view easily
A Swift Popup Module help you popup your custom view easily

JFPopup JFPopup is a Swift Module help you popup your custom view easily. Support 3 way to popup, Drawer, Dialog and BottomSheet. Example To run the e

⛩ Presenting custom views as a popup in iOS.
⛩ Presenting custom views as a popup in iOS.

FFPopup is a lightweight library for presenting custom views as a popup. Bounce from Top & Bounce to Bottom Bounce from Top & Bounce to Top Bounce in

ReleaseNotesKit - a brand new, elegant, and extremely simple way to present the recent version’s release notes to your users
ReleaseNotesKit - a brand new, elegant, and extremely simple way to present the recent version’s release notes to your users

ReleaseNotesKit This is ReleaseNotesKit, a brand new, elegant, and extremely simple way to present the recent version’s release notes to your users. R

Highly configurable iOS Alert Views with custom content views
Highly configurable iOS Alert Views with custom content views

NYAlertViewController NYAlertViewController is a replacement for UIAlertController/UIAlertView with support for content views and UI customization. Fe

A simple custom popup dialog view for iOS written in Swift. Replaces UIAlertController alert style.
A simple custom popup dialog view for iOS written in Swift. Replaces UIAlertController alert style.

A simple custom popup dialog view for iOS written in Swift. Replaces UIAlertController alert style.

Light and scrollable view controller for tvOS to present blocks of text
Light and scrollable view controller for tvOS to present blocks of text

TvOSTextViewer Light and scrollable view controller for tvOS to present blocks of text Description TvOSTextViewer is a view controller to present bloc

IAMPopup is a simple class for expressing custom popup in various forms.
IAMPopup is a simple class for expressing custom popup in various forms.

IAMPopup Introduction IAMPopup is a simple class for expressing custom popup in various forms. This includes where to display the popup and space to d

ToastSwiftUI-master - A simple way to show a toast or a popup in SwiftUI

ToastSwiftUI-master - A simple way to show a toast or a popup in SwiftUI

iOS custom controller used in Jobandtalent app to present new view controllers as cards
iOS custom controller used in Jobandtalent app to present new view controllers as cards

CardStackController iOS custom controller used in the Jobandtalent app to present new view controllers as cards. This controller behaves very similar

The fastest and easiest way to present a UITableView - in 3 lines of code.
The fastest and easiest way to present a UITableView - in 3 lines of code.

Swift Table The fastest and easiest way to present a UITableView - in 3 lines of code. Powered by Generics to present any data type. No need to use th

A custom SwiftUI modifier to present an ActionSheet or a Popover menu
A custom SwiftUI modifier to present an ActionSheet or a Popover menu

ActionOver A custom SwiftUI modifier to present an Action Sheet on iPhone and a Popover on iPad and Mac. iPhone Preview iPad Preview Mac Preview Featu

Comments
  • TvOS

    TvOS

    Install pod with popupkit it show error saying version 3.0.1 is not supported by tvos. But in notes you have mentioned its supported can any one help me with this?

    question 
    opened by variaankitb 2
  • Adding View controller as popup disable button action

    Adding View controller as popup disable button action

    Hey,

    First of all, great library thanks!

    I have problem when I add view controller as popup. In my popup view controller I have IBAction with is en class that not getting called but I can tap on the button.

    How can I fix it?

    Thanks!!

    opened by RonGafni 1
  • Animation for showing background mask looks broken

    Animation for showing background mask looks broken

    Hi,

    when running the example project, I noticed that the animation for showing the background mask looks broken. If doesn't fade in. The animation for removing the background mask works though.

    opened by SwiftyGuerrero 1
  • Popover doesn't work in landscape mode

    Popover doesn't work in landscape mode

    Thank you for this amazing library. It works really well, and simplifies a developer's life tremendously especially if you are bored with the standard iOS alerts. However, I noticed that popover orientations are not correct in the landscape mode, including the example project. When you select Bounce from top animation and if you are in landscape orientation, popover slides from left and with the wrong rotation. See screenshot below (I am running the iOS 12.1 version emulator):

    simulator screen shot - iphone 8 plus - 2019-01-23 at 20 33 40

    When I use the debugger, I can see the code going into the right switch statement in the (void)updateForInterfaceOrientation function but the final frame calculations still happen as though the orientation is portrait. Do you have any plans of adding this as an enhancement?

    opened by BenderNK 2
Releases(3.1.1)
Owner
Pointwelve
Pointwelve
⛩ Presenting custom views as a popup in iOS.

FFPopup is a lightweight library for presenting custom views as a popup. Bounce from Top & Bounce to Bottom Bounce from Top & Bounce to Top Bounce in

JonyFang 828 Jan 5, 2023
IAMPopup is a simple class for expressing custom popup in various forms.

IAMPopup Introduction IAMPopup is a simple class for expressing custom popup in various forms. This includes where to display the popup and space to d

Hosung Kang 18 Dec 29, 2022
SSToastMessage is written purely in SwiftUI. It will add toast, alert, and floating message view over the top of any view. It is intended to be simple, lightweight, and easy to use. It will be a popup with a single line of code.

SSToastMessage SSToastMessage is written in SwiftUI. It will add toast, alert, and floating message view over the top of any view. It is intended to b

Simform Solutions 223 Dec 2, 2022
Simple Swift class for iOS that shows nice popup windows with animation.

NMPopUpView Simple class for iOS that shows nice popup windows, written in Swift. The project is build with Swift 4.0, so you need Xcode 9.0 or higher

Nikos Maounis 194 Jun 5, 2022
A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style.

Introduction Popup Dialog is a simple, customizable popup dialog written in Swift. Features Easy to use API with hardly any boilerplate code Convenien

Orderella Ltd. 3.8k Dec 20, 2022
PopupWindow is a simple Popup using another UIWindow in Swift

PopupWindow PopupWindow is a simple Popup using another UIWindow Feature PopupWindow can be displayed at the top or bottom of the screen. Popup can se

shinji hayashi 415 Dec 5, 2022
The library allows to create simple popup menus

react-native-popup-menu This library allows to create simple popup menus Installation "react-native-popup-menu": "sergeymild/react-native-popup-menu"

SergeyMild 0 Aug 20, 2022
STPopup provides STPopupController, which works just like UINavigationController in popup style, for both iPhone and iPad. It's written in Objective-C and compatible with Swift.

STPopup STPopup provides STPopupController, which works just like UINavigationController in popup style, for both iPhone and iPad. It's written in Obj

Kevin Lin 2.6k Jan 6, 2023
A framework for presenting bars and view controllers as popup, much like the look and feel of Apple Music App.

PBPopupController PBPopupController is a framework for presenting bars and view controllers as popup, much like the look and feel of Apple Music App.

Patrick 58 Dec 3, 2022
PopupController is a controller for showing temporary popup view.

PopupController PopupController is a controller for showing temporary popup view. Demo Try PopupController on Appetize.io Installation CocoaPods pod '

daisuke sato 338 Dec 14, 2022