123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- import UIKit
- open class SideViewController: UIViewController, PresentViewController {
- public var animator: PresentAnimatable = SideAnimator()
- open var animationView: UIView? {
- return nil
- }
- override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
- super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
- commonInit()
- }
- public required init?(coder aDecoder: NSCoder) {
- super.init(coder: aDecoder)
- commonInit()
- }
- override open func viewDidLoad() {
- super.viewDidLoad()
- view.isUserInteractionEnabled = true
- view.backgroundColor = UIColor(gray: 52, alpha: 0)
- configurationGestures()
- }
- private func commonInit() {
- modalPresentationStyle = .custom
- setTransitioningDelegate(self)
- }
- @objc public func disappear() {
- dismiss(animated: true, completion: nil)
- }
- }
- fileprivate extension SideViewController {
- func configurationGestures() {
- configurationTapGesture()
- configurationSwipeGesture()
- }
- func configurationTapGesture() {
- let tap = UITapGestureRecognizer(target: self, action: #selector(disappear))
- tap.setDelegate(self)
- view.addGestureRecognizer(tap)
- }
- func configurationSwipeGesture() {
- let swipe = UISwipeGestureRecognizer(target: self, action: #selector(disappear))
- swipe.setDelegate(self)
- swipe.direction = .left
- view.addGestureRecognizer(swipe)
- }
- }
|