我正在设计一个从右到左的应用程序。我已经使用这行代码将所有内容都设为 rtl:
UIView.appearance().semanticContentAttribute = .forceRightToLeft
这对一切都有效,除了我的导航 Controller 的交互式弹出手势。 segue 的方向是正确的:
但是当我想使用弹出手势(从左边缘滑动到右边缘)时, View 从另一侧可见。
我应该如何更改它?
我试过将边缘更改为 .right 但这禁用了手势识别器:
let gesture = interactivePopGestureRecognizer as! UIScreenEdgePanGestureRecognizer
gesture.edges = .right
最佳答案
您应该同时更改view
和navigationBar
语义属性
使用这个扩展:
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/