Simple Swift class for iOS that shows nice popup windows with animation.

Related tags

Popup swift ios
Overview

Version License Platform 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 to use it.

Installation

Automatic installation using CocoaPods

Add this to your podfile and run pod install:

pod "NMPopUpViewSwift"

Manual installation

To use it in your application, just import PopViewControllerSwift.swift (or PopViewController.h, PopViewController.m if you want to use the Objective-C version. If you still need the Objective-C version, download manually version 2.1 from here), PopViewController.xib and PopViewController_iPad.xib, PopViewController_iPhone6.xib, PopViewController_iPhone6Plus.xib files (or the NMPopUpViewController group from the example project) in your project:

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Swift

var popViewController : PopUpViewController = PopUpViewControllerSwift(nibName: "PopUpViewController", bundle: nil)

and call the pop up using this code in Swift:

popViewController.title = "This is a popup view"
popViewController.showInView(self.view, withImage: UIImage(named: "typpzDemo"), withMessage: "You just triggered a great popup window", animated: true)

To get the appropriate .xib for your screen size declare the popUp as a forced unrapped variable and then use a method similar to the one below in order to call it:

var popViewController : PopUpViewControllerSwift!

@IBAction func showPopUp(sender: AnyObject) {
        let bundle = NSBundle(forClass: PopUpViewControllerSwift.self)
        if (UIDevice.currentDevice().userInterfaceIdiom == .Pad)
        {
            self.popViewController = PopUpViewControllerSwift(nibName: "PopUpViewController_iPad", bundle: bundle)
            self.popViewController.title = "This is a popup view"
            self.popViewController.showInView(self.view, withImage: UIImage(named: "typpzDemo"), withMessage: "You just triggered a great popup window", animated: true)
        } else
        {
            if UIScreen.mainScreen().bounds.size.width > 320 {
                if UIScreen.mainScreen().scale == 3 {
                    self.popViewController = PopUpViewControllerSwift(nibName: "PopUpViewController_iPhone6Plus", bundle: bundle)
                    self.popViewController.title = "This is a popup view"
                    self.popViewController.showInView(self.view, withImage: UIImage(named: "typpzDemo"), withMessage: "You just triggered a great popup window", animated: true)
                } else {
                    self.popViewController = PopUpViewControllerSwift(nibName: "PopUpViewController_iPhone6", bundle: bundle)
                    self.popViewController.title = "This is a popup view"
                    self.popViewController.showInView(self.view, withImage: UIImage(named: "typpzDemo"), withMessage: "You just triggered a great popup window", animated: true)
                }
            } else {
                self.popViewController = PopUpViewControllerSwift(nibName: "PopUpViewController", bundle: bundle)
                self.popViewController.title = "This is a popup view"
                self.popViewController.showInView(self.view, withImage: UIImage(named: "typpzDemo"), withMessage: "You just triggered a great popup window", animated: true)
            }
        }
    }

Objective-C

PopUpViewControllerSwift *popViewController = [[PopUpViewControllerSwift alloc]
                                         initWithNibName:@"PopUpViewController" bundle:nil];
[popViewController setTitle:@"This is a popup view"];
[popViewController showInView:self.view
                   withImage:[UIImage imageNamed:@"yourImage"]
                   withMessage:@"Your Message" animated:YES];

Final output is shown below:

alt tag

A walkthrough tutorial for the Objective-C version can be found here and for the Swift version here.

The MIT License (MIT)

Copyright (c) 2013 Nikos Maounis

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Comments
  • Close Button doesn't work in Swift

    Close Button doesn't work in Swift

    I've read all the issues and I still cant manage to make the close button work. I imported the PopUpViewController.xib and the PopUpViewControllerSwift.swift files, do I need to import any other files?

    bug question 
    opened by omardlhz 31
  • Objective-C button close not works

    Objective-C button close not works

    Hello,

    I use only Objective-C version, not Swift.

    • I integrate PopUpViewController.h and PopUpViewController.m.
    • I create a .xib with button close like your exemple.
    • I code it to open :
    - (void)openPopup
    {
        PopUpViewController *popViewController = [[PopUpViewController alloc] initWithNibName:@"NbArticlesPopUpViewController" bundle:nil];
    
        [popViewController setTitle:@"This is a popup view"];
         [popViewController showInView:self.parentViewController.view
         withImage:[UIImage imageNamed:@"yourImage"]
         withMessage:@"Message" animated:YES];
    }
    

    The popup launch but the button close crash application.…

    Thanks for help....

    question 
    opened by Paul75 18
  • Connect button doesnt work

    Connect button doesnt work

    Hi, I work in swift. I imported the .xib and PopUpViewControllerSwift.swift files, design my layout in the xib files, link my outlet, and write my actions methods for buttons. Treatment i do on my outlet (for example, add border in my button) work perfectly. But when i connect a button with a @IBAction, connect work well, but when i click on the button, nothing happens (if i put a breakpoint, i notice this doesnt enter in the method)

    File's Owner capture d ecran 2015-10-22 a 15 30 11

    capture d ecran 2015-10-22 a 16 02 21

    My method closePopUp capture d ecran 2015-10-22 a 15 29 21

    opened by Persilos 8
  • Undeclared type PopUpViewController

    Undeclared type PopUpViewController

    If you use the below code , with the class PopUpViewControllerSwift it will throw an error var popViewController : PopUpViewController = PopUpViewControllerSwift(nibName: "PopUpViewController", bundle: nil)

    So please change the code to ,

    var popViewController : PopUpViewControllerSwift = PopUpViewControllerSwift(nibName: "PopUpViewController", bundle: nil)

    or else change the swift file name and use it.

    opened by rizwan95 4
  • PopUp does not take the full size of the screen

    PopUp does not take the full size of the screen

    Hello,

    Thank you for your project, it will help me a lot ! However, I do have a problem. I have copied your sample code in my project, but when I try to run it on a simulator, the popUp does not take the full size of the screen. There is some white space on the bottom and the right side (see picture attached).

    What should I do to fix it ? I am on Xcode 6.1.1, and am building on iOS 8.1

    Cheers, screen shot 2014-12-12 at 11 24 43

    bug 
    opened by gjgd 4
  • Correct the spelling of CocoaPods in README

    Correct the spelling of CocoaPods in README

    This pull requests corrects the spelling of CocoaPods 🤓 https://github.com/CocoaPods/shared_resources/tree/master/media

    Created with cocoapods-readme.

    opened by ReadmeCritic 2
  • popup view not working in simulator and xcode 6 with ios 8

    popup view not working in simulator and xcode 6 with ios 8

    Popup not working when i run the app in simulator but in device its working. As well as its not showing when i use iPhone 6 and iPhone 6+ devises. i have developed the application Xcode 6 + iOS 7.1.

    question 
    opened by pivotalraydius 2
  • Add GIF to README

    Add GIF to README

    Hey @psy2k, your lib is really cool, but your README can have some improvements. Since you have an UI Library, it would be good to add a gif to show to devs how it looks like. You can get some inspiration from this lib

    opened by lfarah 1
  • Crash when click closed

    Crash when click closed

    In swift version. I have issue when click on close button. And find out how to fix it. On MainViewController if should be

    var popViewController : PopUpViewControllerSwift = PopUpViewControllerSwift(nibName: "PopUpViewController", bundle: nil)
    popViewController.title = "This is a popup view"
    addChildViewController(popViewController)
    popViewController.showInView(self.view, withImage: UIImage(named: "01"), withMessage: "You just triggered a great popup window", animated: true)
    popViewController.didMoveToParentViewController(self)
    

    Add 2 lines of code :

    addChildViewController(popViewController)
    
    popViewController.didMoveToParentViewController(self)
    
    opened by tanbuu1205 1
  • I can't see the IBOutlet in the XIB

    I can't see the IBOutlet in the XIB

    First of all your NMPopUpView looks great but I have a small issue that I can't see the IBOutlet in the .XIB files while I'm using objective C. Once I upload the swift file I can see the IBOutlet. Please how I can match the .XIB with the objective C files? Issue with PopUpViewController.xib & PopUpViewController_iPhone6.xib

    Also I'm using storyboard.

    Thanks.

    question 
    opened by LuaiKalkatawi 1
  • Configurable properties

    Configurable properties

    Popup Image and message can now be set via the method called from the method you use to call the popup. This way you can have multiple different popups within your app.

    enhancement 
    opened by psy2k 0
Releases(v4.2.2)
Owner
Nikos Maounis
iOS Developer @Sync-Tech. Living in Athens, Greece.
Nikos Maounis
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

逸风 77 Dec 14, 2022
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
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
Simple way to present custom views as a popup in iOS and tvOS.

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 h

Pointwelve 59 Mar 1, 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
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
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
Show MS Windows style activation dialog on my screen.

Activate Mac The "Activate Windows" watermark ported to macOS with Swift Objective-C. Special thanks: MrGlockenspiel/activate-linux for the idea. Inst

Lakr Aream 195 Dec 23, 2022
⛩ 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
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
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
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

Shezad Ahamed 37 Oct 2, 2022
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
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

Quan Tran 384 Dec 29, 2022
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_

Lee Sun-Hyoup 117 Aug 5, 2022
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

Daniel Huri 6.1k Jan 6, 2023
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

Icalia Labs 2.9k Jan 3, 2023
Popover is a balloon library like Facebook app. It is written in pure swift.

Popover Description and appetize.io`s DEMO Usage To run the example project, clone the repo, and run pod install from the Example directory first. Sim

Yusuke Takahashi 2k Jan 2, 2023
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

Hankyeol Park 7 Nov 23, 2022
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

逸风 77 Dec 14, 2022