mickspecial / Card-Slideover

Slide up view for iOS

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Slide Up Card Controller

Purpose

see Use Case 1

see Use Case 2

Slide Up Card Controller aims to be a lightweight solution for the above use cases. For those that want a more robust solution pulley may be better suited to you


Usage

  1. Drag the Card folder into your project
  2. Set up the Card View Controller on the desired view controller

class ViewController: UIViewController {

  // 1. Set instance var for the card controller
  var cardViewController: CardViewController!
  
  override func viewWillAppear(_ animated: Bool) {
    super.viewWillAppear(animated)
    
    // 2. Set up card after the parent VC has been layed out
   if cardViewController == nil {
      cardViewController = CardViewController()
      cardViewController.place(on: self, percentageShownWhenExpanded: 0.7)
      
      // 3. Optional - extend the class with CardStateNotification protocol
      registerForCardStateChanges()
      }
    }
}

extension ViewController: CardStateNotification {
  
  // allows the parent to access / respond to card state changes
  func cardStateDidChange() {
    print(cardViewController.currentCardState.rawValue)
  }
}

Preview

preview


Enjoy

About

Slide up view for iOS

License:MIT License


Languages

Language:Swift 100.0%