AllDirectionsDismiss 1.1.2

AllDirectionsDismiss 1.1.2

Maintained by kohei1218.



  • By
  • kohei1218

Cocoapods Carthage compatible Cocoapods platforms Cocoapods Swift 4.2 Swift 5.0 Swift 5.1

AllDirectionsDismiss

AllDirectionsDismiss makes it easy for anyone to dismiss a ViewController by swiping in all four directions. Not only views, but UIScrollView, UITableView, and UICollectionView can all be smoothly dismissed.

single_view scrollview

Feature

  • Easy to use
  • custom background view color, alpha
  • custom dismissable percent, velocity
  • set custom background view
  • set background blur view

Usage

use with ScrollView, TableView, CollectionView

import UIKit
import AllDirectionsDismiss

// set member variable
var allDirectionsDismiss: AllDirectionsDismiss?

class ViewController: UIViewController {
    override func viewDidLoad() {
        super.viewDidLoad()

        // initialize with scrollView
        allDirectionsDismiss = AllDirectionsDismiss(scrollView: tableView)
        // set percent to dismiss
        allDirectionsDismiss?.dismissPercent = 0.3
        // set velocity to dismiss
        allDirectionsDismiss?.dismissVelocity = 1000
        // set alpha to background view alpha
        allDirectionsDismiss?.backgroundAlpha = 0.9
        // set alpha to background view color
        allDirectionsDismiss?.backgroundColor = .black
    }
}

If you're using a ScrollView, the top and bottom If you want to add a dismissal, use the addDismissGesture(view: UIView) You can use it.

let headerView = UIView()
allDirectionsDismiss?.addDismissGesture(view: headerView)

use with ViewController

import UIKit
import AllDirectionsDismiss

class ViewController: UIViewController {

    var allDirectionsDismiss: AllDirectionsDismiss?
    
    override func viewDidLoad() {
        super.viewDidLoad()
        title = "Single"
        
        // initialize with UIViewController
        allDirectionsDismiss = AllDirectionsDismiss(viewController: self)
        // set percent to dismiss
        allDirectionsDismiss?.dismissPercent = 0.3
        // set velocity to dismiss
        allDirectionsDismiss?.dismissVelocity = 1000
        // set alpha to background view alpha
        allDirectionsDismiss?.backgroundAlpha = 0.9
        // set alpha to background view color
        allDirectionsDismiss?.backgroundColor = .black
    }
    
}

Customize

allowDismissDirection

You can specify the direction of the dismissal to be allowed.

default value is [.down, .up, .left, .right]

allDirectionsDismiss?.allowDismissDirection = [.up, .right]

dismissPercent

You can specify the percentages to dismiss.

default value is 0.3 (min is 0, max is 1)

allDirectionsDismiss?.dismissPercent = 0.15

dismiss_percent

dismissVelocity

You can specify the velocity to dismiss.

default value is 500 (min is 0, max is 1000)

allDirectionsDismiss?.dismissVelocity = 1000

dismiss_velocity

backgroundAlpha

You can change the alpha of the background.

default value is 0.9 (min is 0, max is 1)

allDirectionsDismiss?.backgroundAlpha = 0.0

background_alpha

backgroundColor

You can change the color of the background.

default color is black.

allDirectionsDismiss?.backgroundColor = .red

background_color

Installation

Carthage

  • Add github "kohei1218/AllDirectionsDismiss" to your Cartfile.
  • Run carthage update.

CocoaPods

  • Add pod 'AllDirectionsDismiss' to your Podfile.
  • Run pod update.

Requirements

  • iOS 10.0 or later

Contributing

PullRequest and stars are welcome!

If you find a bug, please report it in the issue. If you want to help me develop, please send me a PullRequest!

Author

License

AllDirectionsDismiss is released under the MIT license. See LICENSE for details.