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.
- Easy to use
- custom background view color, alpha
- custom dismissable percent, velocity
- set custom background view
- set background blur view
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)
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
}
}
You can specify the direction of the dismissal to be allowed.
default value is [.down, .up, .left, .right]
allDirectionsDismiss?.allowDismissDirection = [.up, .right]
You can specify the percentages to dismiss.
default value is 0.3 (min is 0, max is 1)
allDirectionsDismiss?.dismissPercent = 0.15
You can specify the velocity to dismiss.
default value is 500 (min is 0, max is 1000)
allDirectionsDismiss?.dismissVelocity = 1000
You can change the alpha of the background.
default value is 0.9 (min is 0, max is 1)
allDirectionsDismiss?.backgroundAlpha = 0.0
You can change the color of the background.
default color is black.
allDirectionsDismiss?.backgroundColor = .red
- Add it as a dependency within your Package.swift manifest:
dependencies: [
.package(url: "https://github.com/kohemon/AllDirectionsDismiss.git", from: "1.1.4")
]
- iOS 10.0 or later
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!
- @kohei1218 / kohei saito
AllDirectionsDismiss is released under the MIT license. See LICENSE for details.