Swiftpack.co - Package - antoniocasero/Panels

Build Status Carthage compatible CocoaPods Platform Language


Panels is a framework to easily add sliding panels to your application. It takes care of the safe area in new devices and moving your panel when the keyboard is presented/dismissed.

Updated to Swift 5.1

Sliding Panel demo1 Sliding Panel demo2 Sliding Panel demo3


First, create your own panel, you can use Interface Builder, use as reference the examples provided. Make sure that you conform the protocol Panelable

import UIKit
import Panels

class PanelOptions: UIViewController, Panelable {
    @IBOutlet var headerHeight: NSLayoutConstraint!
    @IBOutlet var headerPanel: UIView!

This protocol defines the interface needed to be able to adjust the sliding panel to the container, expanding and collapsing. It will take care of the safe area

Then in your ViewController, where the panel is presented:

class YourViewController: UIViewController {
    lazy var panelManager = Panels(target: self)
    override func viewDidLoad() {
        let panel = UIStoryboard.instantiatePanel(identifier: "YourPanelName")
        let panelConfiguration = PanelConfiguration(size: .oneThird)
        // To present the panel
        panelManager.show(panel: panel, config: panelConfiguration)
        // To dismiss the panel

If you want to get notifications when the panel is presented, collapsed or expanded, just conform the protocol PanelNotifications

You can find extra options in the PanelConfiguration object:

    /// Storyboard name, the first Viewcontroller will be instantiated
    public var panelName: String

    /// Panel height
    public var panelSize: PanelDimensions

    /// Panel margins between the header and the next views.
    public var panelMargin: CGFloat

    /// Visible area when the panel is collapsed
    public var panelVisibleArea: CGFloat

    /// Safe area is avoided if this flag is true.
    public var useSafeArea = true

    /// Collapse and expand when tapping the header view.
    public var respondToTap = true

    /// Collapse and expand when dragging the header view.
    public var respondToDrag = true

    /// Collapse when tapping outside the panel
    public var closeOutsideTap = true

    /// Animate the panel when the superview is shown.
    public var animateEntry = false

    /// If parent view is a navigationcontroller child, this flag allow a better calculation when the panelSize is .fullScreen
    public var enclosedNavigationBar = true

You could add an arrow indicator to give more feedback to your panels. The perfect companion for Panels is Arrows

Arrows Example



Add the line pod "Panels" to your Podfile


Add the line github "antoniocasero/Panels" to your Cartfile


dependencies: [
  .package(url: "https://github.com/antoniocasero/Panels.git", from: "2.2.3")


Project created by Antonio Casero (@acaserop on Twitter).


Sketch UI (Elements)


Stars: 1379


Used By

Total: 0


- 2020-02-05 21:38:20

- 2020-02-05 21:33:31

- 2020-02-05 21:30:17

- 2020-02-05 21:20:58

- 2019-06-20 09:21:59

v2.0.3 - 2018-10-29 10:18:43

Support for iOS9 thanks to @jondwillis Fix for #7

V2.0.2 - 2018-10-10 19:34:40

Minor Fixes:

Fix #3

v2.0.1 - 2018-10-09 21:07:51

This release fixes autolayout conflicts

v2.0.0 - 2018-10-08 20:52:46

This version brings breaking changes in the API

  • Panels constructor needs the parent view controller
  • addPanel function has been replaced by show
  • Added new method to dismiss the panel
  • Unit tests and integration tests