Awalz / SwiftyCam

A Snapchat Inspired iOS Camera Framework written in Swift
BSD 2-Clause "Simplified" License
2.08k stars 327 forks source link

Adding new gesture recognizer to view #233

Closed mburdzy closed 3 years ago

mburdzy commented 3 years ago

Has anyone here been able to add their own gesture recognizers without changing the SwiftyCam code?

I see AddGestureRecognizers is set as fileprivate and so is previewLayer, so I am wonder if there is a simple way to add my own custom swipe gesture recognizer without needing to do a pull request.

mburdzy commented 3 years ago

Figured it out on my own.

Was able to do it by adding these two functions

private func addSwipe() { Swipe = UISwipeGestureRecognizer(target: self, action: #selector(swipeGesture(swipe:))) Swipe!.delegate = self Swipe!.direction = .left self.view.addGestureRecognizer(Swipe!) }

func gestureRecognizer(_ gestureRecognizer: UIGestureRecognizer, shouldRecognizeSimultaneouslyWith otherGestureRecognizer: UIGestureRecognizer) -> Bool {
    return true
}`