6

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
Arash Etemad
  • 1,827
  • 1
  • 13
  • 29
abdollah zakeri
  • 364
  • 3
  • 11
  • 1
    now your problem is with UINavigationController that when you swipe from left to right you want present the sideMenu but it goes back to past viewController, am I right ? – Arash Etemad Apr 29 '18 at 08:09
  • سلام.نه مشکلم اینه که وقتی صفحه رو‌از چپ میکشم راست اون @arashترنزیشنی که انجام میشه برعکسشه.یعنی من از چپ به راست میکشم این صفحه بالایی از راست به چپ حرکت میکنه.دقیقا تو اسنپ صفحه پروفایلش این رو درستش رو پیاده کرده از راست میکشی به چپ صفحه هم تو همون جهت حرکت میکنه ولی مال من جهت حرکت صفحم درسته جهت اون سوایپ جسچر برعکسه – abdollah zakeri Apr 29 '18 at 20:43
  • do you use any GitHub library ? – Arash Etemad Apr 30 '18 at 04:40
  • no i use uinavigationController and the gesture is the default pop gesture wich is implemented in that class.@arash – abdollah zakeri Apr 30 '18 at 06:10

2 Answers2

11

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
    }
}
Arash Etemad
  • 1,827
  • 1
  • 13
  • 29
0

It works for me using UINavigationController instead of UIViewController:

extension UINavigationController {
    open override func awakeFromNib() {
        super.awakeFromNib()
        navigationController?.view.semanticContentAttribute = .forceRightToLeft
        navigationController?.navigationBar.semanticContentAttribute = .forceRightToLeft
    }
}
fcdt
  • 2,371
  • 5
  • 14
  • 26