ios - UINavigationController 改变 InteractivePopGesture 方向

标签 ios swift swift3 uinavigationcontroller uigesturerecognizer

我正在设计一个从右到左的应用程序。我已经使用这行代码将所有内容都设为 rtl:

UIView.appearance().semanticContentAttribute = .forceRightToLeft

这对一切都有效,除了我的导航 Controller 的交互式弹出手势。 segue 的方向是正确的:

enter image description here

但是当我想使用弹出手势(从左边缘滑动到右边缘)时, View 从另一侧可见。
我应该如何更改它?
我试过将边缘更改为 .right 但这禁用了手势识别器:

let gesture = interactivePopGestureRecognizer as! UIScreenEdgePanGestureRecognizer
    gesture.edges = .right

最佳答案

您应该同时更改viewnavigationBar 语义属性
使用这个扩展:

extension UIViewController {
    open override func awakeFromNib() {
        super.awakeFromNib()
        navigationController?.view.semanticContentAttribute = .forceRightToLeft
        navigationController?.navigationBar.semanticContentAttribute = .forceRightToLeft
    }
}

关于ios - UINavigationController 改变 InteractivePopGesture 方向,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50045243/

相关文章:

swift - 需要显式管理 Swift Package 嵌套依赖项吗?

ios - 文件管理器在 iOS 7 上不工作

swift - 用户输入作为全局变量以显示来自不同 View 的文本

ios - 有没有一种方法可以从 ABAddressBookGetAuthorizationStatus 模拟 (.NotDetermined) 状态?

ios - pod install 'PayPal-iOS-SDK' 失败,继续安装 CardIO (5.3.2)

arrays - 无法分配给属性 : 'itemArray' is a get-only property

ios - 获取之前的 UINavController

iOS:禁止 "Open in..."菜单并立即在特定应用程序中打开附加的电子邮件文件

ios - 在 `touchesBegan:withEvent:` 之后禁用所有 UIPanGestureRecognizers

ios - 无法将试用应用程序上传到 iPhone 进行测试