UINavigationController更改InteractivePopGesture方向

abd*_*eri 4 uinavigationcontroller uigesturerecognizer ios swift swift3

我正在设计一个从右到左的应用程序。通过使用以下代码行,我将所有内容设置为rtl:

UIView.appearance().semanticContentAttribute = .forceRightToLeft
Run Code Online (Sandbox Code Playgroud)

并且对所有期望我的导航控制器具有交互弹出手势的东西来说都是正确的。正确的方向:

在此处输入图片说明

但是当我要使用弹出手势(从左边缘向右边缘滑动)时,从相反的一侧可以看到该视图。
我该如何更改?
我尝试将边缘更改为.right,但是禁用了手势识别器:

let gesture = interactivePopGestureRecognizer as! UIScreenEdgePanGestureRecognizer
    gesture.edges = .right
Run Code Online (Sandbox Code Playgroud)

Ara*_*mad 5

您应该同时更改两者viewnavigationBar语义属性,
使用此扩展名:

extension UIViewController {
    open override func awakeFromNib() {
        super.awakeFromNib()
        navigationController?.view.semanticContentAttribute = .forceRightToLeft
        navigationController?.navigationBar.semanticContentAttribute = .forceRightToLeft
    }
}
Run Code Online (Sandbox Code Playgroud)