Created
September 17, 2016 11:53
-
-
Save kumamotone/d693b9badf7bc5ac1b62d7bd8bae15d7 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import UIKit | |
protocol SwipeReturnable { | |
func addSwipeReturnGesture() | |
} | |
extension SwipeReturnable where Self: UIViewController { | |
func addSwipeReturnGesture() { | |
let gestureToRight = UISwipeGestureRecognizer(target: self, action: #selector(self.swipeBack)) | |
gestureToRight.direction = .Right | |
self.view.addGestureRecognizer(gestureToRight) | |
} | |
} | |
extension UIViewController { | |
@objc private func swipeBack() { | |
self.navigationController?.popViewControllerAnimated(true) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment