|
//
// SideViewController.swift
// PaiAi
//
// Created by ffib on 2018/12/12.
// Copyright © 2018 yb. All rights reserved.
//
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, a: 0)
configurationGestures()
}
private func commonInit() {
modalPresentationStyle = .custom
setTransitioningDelegate(self)
}
@objc public func disappear() {
dismiss(animated: true, completion: nil)
}
}
/// gesture
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)
}
}
|