项目作者: antoniocasero

项目描述 :
Panels is a framework to easily add sliding panels to your application
高级语言: Swift
项目地址: git://github.com/antoniocasero/Panels.git
创建时间: 2018-08-10T09:05:52Z
项目社区:https://github.com/antoniocasero/Panels

开源协议:MIT License

下载




Build Status
Carthage compatible
CocoaPods
Platform
Language

Twitter

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

Usage

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

  1. import UIKit
  2. import Panels
  3. class PanelOptions: UIViewController, Panelable {
  4. @IBOutlet var headerHeight: NSLayoutConstraint!
  5. @IBOutlet var headerPanel: UIView!
  6. }

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:

  1. class YourViewController: UIViewController {
  2. lazy var panelManager = Panels(target: self)
  3. override func viewDidLoad() {
  4. super.viewDidLoad()
  5. let panel = UIStoryboard.instantiatePanel(identifier: "YourPanelName")
  6. let panelConfiguration = PanelConfiguration(size: .oneThird)
  7. // To present the panel
  8. panelManager.show(panel: panel, config: panelConfiguration)
  9. ....
  10. // To dismiss the panel
  11. panelManager.dismiss()
  12. }
  13. }

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:

  1. /// Storyboard name, the first Viewcontroller will be instantiated
  2. public var panelName: String
  3. /// Panel height
  4. public var panelSize: PanelDimensions
  5. /// Panel margins between the header and the next views.
  6. public var panelMargin: CGFloat
  7. /// Visible area when the panel is collapsed
  8. public var panelVisibleArea: CGFloat
  9. /// Safe area is avoided if this flag is true.
  10. public var useSafeArea = true
  11. /// Collapse and expand when tapping the header view.
  12. public var respondToTap = true
  13. /// Collapse and expand when dragging the header view.
  14. public var respondToDrag = true
  15. /// Collapse when tapping outside the panel
  16. public var closeOutsideTap = true
  17. /// Animate the panel when the superview is shown.
  18. public var animateEntry = false
  19. /// If parent view is a navigationcontroller child, this flag allow a better calculation when the panelSize is .fullScreen
  20. 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

Installation

CocoaPods

Add the line pod "Panels" to your Podfile

Carthage

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

SPM

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

Author

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

Credits

Sketch UI (Elements)