Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

UINavigationController change InteractivePopGesture direction

I am designing a right to left application.I've made everything rtl by using this line of code:

UIView.appearance().semanticContentAttribute = .forceRightToLeft

and that works correct for everything expect the interactive pop gesture of my navigation controller. the direction of the segue is correct:

enter image description here

but when I want to use the pop gesture (swipe from left edge to right edge) the view become visible from opposite side.
How should I change it?
I've tried changing the edges to .right but that disabled the gesture recognizer :

let gesture = interactivePopGestureRecognizer as! UIScreenEdgePanGestureRecognizer
    gesture.edges = .right
like image 345
abdollah zakeri Avatar asked Jan 03 '23 11:01

abdollah zakeri


1 Answers

You should change the both view and navigationBar semantic attribute
use this extension:

extension UIViewController {
    open override func awakeFromNib() {
        super.awakeFromNib()
        navigationController?.view.semanticContentAttribute = .forceRightToLeft
        navigationController?.navigationBar.semanticContentAttribute = .forceRightToLeft
    }
}
like image 188
Arash Etemad Avatar answered Jan 05 '23 19:01

Arash Etemad