DASlideViewController 0.1.2

DASlideViewController 0.1.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jul 2015
SPMSupports SPM

Maintained by Dan Appel.



  • By
  • Dan Appel

DASlideViewController

Demo

Demo Gif

Usage

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

None!

Installation

DASlideViewController is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod "DASlideViewController"

Quickstart

Getting started is very simple.

The sample project should tell you everything that you need, but if you want a slightly more detailed walkthrough, this is a list of what you need to do:

  • Create a standard view controller, and make sure it is a subclass of DASlideViewController, ex:
import UIKit
import DASlideViewController
class ViewController: DASlideViewController  {
}
  • For each tab that you want, create a container view. Set it’s width/height to whatever you want (probably equal to the viewcontroller), it will work either way. They can be off the screen - a helper function is provided to organize them (DASlideViewController.setupContainerViewPositions).
  • Give each container view a tag - have the lowest one be 1, second be 2, etc.
  • Make sure that the container view is of type DASlideContainerView
  • Inside the container view (seperate controller, if using storyboard) create something that will act as the tab (ex: label, button, etc.) and give it a label of -1 (you can change this later).
  • The tab’s height can be anything you want - DASlideViewController makes sure there aren’t any overlaps
  • The last UI item you need is a pan gesture recognizer to the main view - make sure it isn’t bound to anything. You need to capture a ‘pan’ event and forward it to DASlideViewController. Refer to the code snippet below on how to do this.

Here’s all the code that you need (if you’re not using storyboard) to get started:

import UIKit
import DASlideViewController

class ViewController: DASlideViewController  {

    @IBAction func pannedScreen(sender: UIPanGestureRecognizer) {
        self.dragViewWithPanGestureRecognizer(sender)
        // ^ forward it to DASlideViewController
    }
    override func viewDidLoad() {
        super.viewDidLoad()
    }
    override func viewDidLayoutSubviews() {
        self.setupContainerViewPositions()
        // move containers into their starting positions
    }
    override func didReceiveMemoryWarning() {
        super.didReceiveMemoryWarning()
    }
}

Author

Dan Appel, [email protected]

License

DASlideViewController is available under the MIT license. See the LICENSE file for more info.