Latest 0.1.0
Homepage https://github.com/allanscofield/SwapDownViewController
License MIT
Platforms ios 10.0, requires ARC
Frameworks UIKit
Authors

Requirements

  • iOS 10.0+
  • Xcode 10.0+
  • Swift 4.2+

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To install it, simply add the following line to your Podfile:

pod 'SwipeDownViewController'

Usage

Showing a single ViewController with swipe down to dismiss


//OriginViewController

import UIKit
//1. Add a import
import SwipeDownViewController

//2. Inherit from SwipeDownOriginViewController
final class ViewController: SwipeDownOriginViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    private func showModal(){
        let vc = storyboard?.instantiateViewController(withIdentifier: "ModalViewController") as! SwipeDownViewController

        //3. Set delegates 
        vc.interactor = self.interactor
        vc.transitioningDelegate = self

        self.present(vc, animated: true, completion: nil)
    }
}

//ModalViewController

import UIKit
//4. Add a import
import SwipeDownViewController

//5. Inherit from SwipeDownViewController
final class ModalViewController: SwipeDownViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
    }
}

Showing a ViewController embedded in a UINavigationController


//OriginViewController

import UIKit
//1. Add a import
import SwipeDownViewController

//2. Inherit from SwipeDownOriginViewController
final class ViewController: SwipeDownOriginViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    private func showModalWithNavigation(){
        let vc = storyboard?.instantiateViewController(withIdentifier: "ModalViewController")
        //3. Inherit from SwipeDownNavigationController
        let nav = SwipeDownNavigationController(with: vc, origin: self)
        self.present(nav, animated: true, completion: nil)
    }
}

//ModalViewController

import UIKit
import SwipeDownViewController

final class ModalViewController: SwipeDownViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
    }
}

Showing a ViewController embedded in a UINavigationController with a UITableView


//OriginViewController

import UIKit
//1. Add a import
import SwipeDownViewController

//2. Inherit from SwipeDownOriginViewController
final class ViewController: SwipeDownOriginViewController {

    override func viewDidLoad() {
        super.viewDidLoad()
    }

    private func showModalWithNavigationAndTableView(){
        let vc = storyboard?.instantiateViewController(withIdentifier: "ModalTableViewController")
        //3. Inherit from SwipeDownNavigationController
        let nav = SwipeDownNavigationController(with: vc, origin: self)
        self.present(nav, animated: true, completion: nil)
    }
}

//ModalViewController

import UIKit
//4. Add a import
import SwipeDownViewController

//5. Inherit from SwipeDownViewController
final class ModalViewController: SwipeDownViewController {

    @IBOutlet weak private var tableView: UITableView!

    override func viewDidLoad() {
        super.viewDidLoad()
        //6. Add this line
        self.addSwipeDownToClose(to: self.tableView)
    }
}

License

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

Latest podspec

{
    "name": "SwipeDownViewController",
    "platforms": {
        "ios": "10.0"
    },
    "summary": "SwipeDownViewController lets a user dismiss a ViewController using a swipe down gesture.",
    "requires_arc": true,
    "version": "0.1.0",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "Allan Scofield": "[email protected]"
    },
    "homepage": "https://github.com/allanscofield/SwapDownViewController",
    "source": {
        "git": "https://github.com/allanscofield/SwapDownViewController.git",
        "tag": "0.1.0"
    },
    "frameworks": "UIKit",
    "source_files": "SwipeDownViewController/Sources/*.{swift}",
    "swift_version": "4.2"
}

Pin It on Pinterest

Share This