Latest 0.1.0
Homepage https://github.com/shin8484/PopupWindow
License MIT
Platforms ios 10.0, requires ARC
Frameworks UIKit
Authors

Version
License
Carthage compatible
Platform

image

PopupWindow is a simple Popup using another UIWindow

Feature

  • PopupWindow can be displayed at the top or bottom of the screen.
  • Popup can set margins, cornerRadius, blur, etc.
  • When displaying blur, you can’t touch the below contents.
  • By erasing blur, you can touch the below contents.
  • Popup are displayed on another window, so you can leave Popup even when screen transitions.
TopToast BottomToast TopCard BottomCard Example
demo_01 demo_02 demo_03 demo_04 demo_05

Installation

CocoaPods

Add PopupWindow to your Podfile:

pod 'PopupWindow'

Carthage

Add PopupWindow to your Cartfile:

github "shin8484/PopupWindow"

Usage

When displaying popup in another window, please call first PopupWindowManager changeKeyWindow(rootViewController: UIViewController)

PopupWindowManager.shared.changeKeyWindow(rootViewController: UIViewController())

Create and show show

Create a PopupItem in the VC where you want to display the popup and call the method of the PopupPresentable protocol

var popupItem: PopupItem = PopupItem(view: LoginView.view(),
                                     frame: Const.firstViewFrame,
                                     type: .rounded(cornerSize: 4),
                                     direction: .top,
                                     margin: 8,
                                     hasBlur: true)

// Methods in PopupPresentable
setupPopupContainerView()
makePopupView(with: popupItem)
showPopupView(duration: Const.popupDuration, curve: .easeInOut, delayFactor: 0.0)

Transform & Replace

Replace the display contents, and perform deformation to the specified size.
By using PopupItem, you can specify content contents and size.

transformPopupView(duration: Const.transformDuration, curve: .easeInOut, popupItem: popupItem) { [weak self] _ in
    guard let me = self else { return }
    me.replacePopupView(with: popupItem)
    me.dismissPopupView(duration: 3.3, curve: .easeInOut, delayFactor: 0.9, direction: .top) { _ in }
}

Dismiss

Specify hide animation direction with PopupViewDirection

dismissPopupView(duration: 3.3, curve: .easeInOut, delayFactor: 0.9, direction: .bottom) { _ in
    PopupWindowManager.shared.changeKeyWindow(rootViewController: nil)
}

PopupItem

PopupItem is struct to set up a popup, View, size, direction, whether it is rounded, margin, blurred or not

struct PopupItem {
    public let view: UIView
    public let frame: CGRect
    public let type: PopupViewType
    public let direction: PopupViewDirection
    public let margin: CGFloat
    public let hasBlur: Bool
}

Requirements

  • iOS 10.0+
  • Xcode 9.1+
  • Swift 3.0.1+

LICENSE

Under the MIT license. See LICENSE file for details.

Latest podspec

{
    "name": "PopupWindow",
    "version": "0.1.0",
    "license": {
        "type": "MIT"
    },
    "homepage": "https://github.com/shin8484/PopupWindow",
    "authors": {
        "Shinji Hayashii": "[email protected]"
    },
    "summary": "Creates and displays Popup on another UIWindow.",
    "source": {
        "git": "https://github.com/shin8484/PopupWindow.git",
        "tag": "0.1.0"
    },
    "platforms": {
        "ios": "10.0"
    },
    "source_files": "PopupWindow/**/*.swift",
    "frameworks": "UIKit",
    "requires_arc": true,
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This