Popularity
1.8
Stable
Activity
6.7
Declining
52
6
8

Description

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

Programming language: Swift
License: MIT License
Tags: Swift     iOS     UI     Popup    
Latest version: v3.4.3

PBPopupController alternatives and similar libraries

Based on the "Popup" category.
Alternatively, view PBPopupController alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of PBPopupController or a related project?

Add another 'Popup' Library

README

PBPopupController

Build Status Carthage compatible Version SwiftPM compatible Mac Catalyst compatible License Platform Swift Version

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

Image

Overview

PBPopupController allows to configure a popup bar (like the mini player of Apple Music App), dock it to the bottom bar of a presenting view container controller (like UITabBarController, UINavigationController). The presenting view controller can be any UIViewController subclass.

Each view controller can present a popup bar, docked to a bottom view. For UITabBarController subclasses, the default is the tab bar. For UINavigationController subclasses, the default view is the toolbar. For other classes, the popup bar is presented at the bottom of the screen. View controller subclasses can provide their own bottom bar views.

Once the popup bar is configured (see the properties in the PBPopupBar class) with a style, an image, a title, a sub-title, buttons, effects and colors, you present it with the above view controller providing a required popup content view controller (like the maxi player of Apple Music App).

Once the popup bar is presented with a popup content view controller, the user can swipe or tap the popup bar at any point to present the content view controller. After finishing, the user dismisses this view controller by either swiping or tapping the popup close button porvided by the system.   Popup close buttons styles are labeled chevron for modern style chevron close button and round for iOS 9-style close buttons.

You can also present and dismiss the popup content view controller programmatically.

The popup bar has a prominent style based on the modern Music app look and feel and below and a compact style for iOS 9-style look and feel.. You can change these default values.

The presentation options provided by the framework are listed in the PBPopupPresentationStyle enumeration. They make the presentation look like the behavior of the Apple Music App. For iOS 9, the presentation style was fullScreen by default and for iOS 10 and below, the style was deck. The default is deck. You can change these default values. The custom option allows you to present the controller on a part of the screen.

Installation

Swift Package Manager

PBPopupController supports SPM versions 5.1.0 and above. To use SPM, you should use Xcode 11 or above to open your project. Click File -> Swift Packages -> Add Package Dependency, enter https://github.com/iDevelopper/PBPopupController. Select the version you’d like to use.

Carthage

Add the following to your Cartfile:

github "iDevelopper/PBPopupController"

Make sure you follow the Carthage integration instructions here.

Manual

Drag the PBPopupController.xcodeproj project to your project, and add PBPopupController.framework to Embedded Binaries in your project target's General tab. Xcode should sort everything else on its own.

CocoaPods

PBPopupController is available for installation using the Cocoa dependency manager CocoaPods.

Add the following to your project's Podfile:

pod 'PBPopupController'

Requirements

  • iOS 11 or later.
  • ARC memory management.

Features

  • Category methods on UIViewController.
  • Handling of rotations.
  • Plays nicely with any child view controllers or parent controllers.
  • Seamless integration of tap and pan gesture recognizers.
  • Delegate methods for getting full state of the controller and implementing your own code hooks for customizing behavior.
  • Data source methods for asking custom popup bar' labels.
  • Full Right-To-Left support.
  • Accessibility support.
  • iOS 13 dark mode support.
  • macOS Catalyst support.
  • iPad look and feel support.

Basic API Description

  • Configuring and presenting a popup bar:

        self.tabBarController?.popupController.delegate = self
    
        if let popupBar = self.tabBarController?.popupBar {
    
            popupBar.dataSource = self
    
            popupBar.image = UIImage(named: "Cover01")
            popupBar.title = "Title"
            popupBar.subtitle = " A subtitle"
            popupBar.accessibilityLabel = "My custom label"
    
            let popupPlayButtonItem = UIBarButtonItem(image: #imageLiteral(resourceName: "play-small"), style: .plain, target: self, action: #selector(playPauseAction(_:)))
            popupPlayButtonItem.accessibilityLabel = NSLocalizedString("Play", comment: "")
            let popupNextButtonItem = UIBarButtonItem(image: #imageLiteral(resourceName: "next-small"), style: .plain, target: self, action: #selector(nextAction(_:)))
            popupNextButtonItem.accessibilityLabel = NSLocalizedString("Next track", comment: "")
    
            popupBar.rightBarButtonItems = [popupPlayButtonItem, popupNextButtonItem]
    
            let popupContentVC = self.storyboard?.instantiateViewController(withIdentifier: "PopupContentViewController") as? PopupContentViewController
    
            self.tabBarController?.presentPopupBar(withPopupContentViewController: popupContentVC, animated: true, completion: {
                print("Presented")
            })
        }
    
  • Opening a popup content view controller programmatically:

        self.tabBarController?.openPopup(animated: true, completion: {
            print("Open")
        })
    
  • Closing a popup content view controller programmatically:

        self.tabBarController?.closePopup(animated: true, completion: {
            print("Closed")
        })
    
  • Delegate methods for getting state of the controller:

    func popupController(_ popupController: PBPopupController, stateChanged state: PBPopupPresentationState, previousState: PBPopupPresentationState) {
        PBLog("stateChanged state: \(state.description) - previousState: \(previousState.description)")
    }
    
    func popupController(_ popupController: PBPopupController, didOpen popupContentViewController: UIViewController) {
        PBLog("didOpen - state: \(popupController.popupPresentationState.description)")
    }
    

    etc...

  • PBPopupBar dataSource methods for providing label instances (such as MarqueeLabel):

    lazy var label: MarqueeLabel = {
        let marqueeLabel = MarqueeLabel(frame: .zero, rate: 15, fadeLength: 10)
        marqueeLabel.leadingBuffer = 0.0
        marqueeLabel.trailingBuffer = 5.0
        marqueeLabel.animationDelay = 1.0
        marqueeLabel.type = .continuous
        return marqueeLabel
    }()
    

    ...

    func titleLabel(for popupBar: PBPopupBar) -> UILabel? {
        return self.label
    }
    
    func subtitleLabel(for popupBar: PBPopupBar) -> UILabel? {
        return self.sublabel
    }
    

Managing the status bar

Since iOSS 13, the staus bar is not animated correctly by Apple. So, you can set the properties:

popupPreferredStatusBarStyle for the preferred status bar style of the popup content view controller, containerPreferredStatusBarStyle for preferred status bar style of the container view controller.

When you override the preferredStatusBarStyle variable in your popup content view controller, return container.popupController.popupStatusBarStyle:

    override public var preferredStatusBarStyle: UIStatusBarStyle {
        guard let containerVC = self.popupContainerViewController else {return.default}
        guard let popupContentView = containerVC.popupContentView else {return .default}

        if popupContentView.popupPresentationStyle != .deck {
            return .default
        }
        return containerVC.popupController.popupStatusBarStyle
    }

API Documentation

You can find the docs here. Documentation is generated with jazzy and hosted on GitHub-Pages.

Special Mention

A Special Thank to Leo Natan.

This code was inspired on his excellent framework LNPopupController.

Author

Patrick BODET aka iDevelopper

License

PBPopupController is available under the MIT license, see the LICENSE file for more information.

Please tell me when you use this controller in your project!

Regards,

Patrick Bodet aka iDevelopper


*Note that all licence references and agreements mentioned in the PBPopupController README section above are relevant to that project's source code only.