UINavigationController 改变 InteractivePopGesture 方向
UINavigationController change InteractivePopGesture direction
我正在设计从右到左 application.I已经使用这行代码将所有内容都设为 rtl:
UIView.appearance().semanticContentAttribute = .forceRightToLeft
这对除我的导航控制器的交互式弹出手势之外的所有内容都有效。
segue 的方向是正确的:
但是当我想使用弹出手势(从左边缘滑动到右边缘)时,视图从另一侧可见。
我应该如何更改它?
我试过将边缘更改为 .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
}
}
我使用 UINavigationController
而不是 UIViewController
:
extension UINavigationController {
open override func awakeFromNib() {
super.awakeFromNib()
navigationController?.view.semanticContentAttribute = .forceRightToLeft
navigationController?.navigationBar.semanticContentAttribute = .forceRightToLeft
}
}
我正在设计从右到左 application.I已经使用这行代码将所有内容都设为 rtl:
UIView.appearance().semanticContentAttribute = .forceRightToLeft
这对除我的导航控制器的交互式弹出手势之外的所有内容都有效。 segue 的方向是正确的:
但是当我想使用弹出手势(从左边缘滑动到右边缘)时,视图从另一侧可见。
我应该如何更改它?
我试过将边缘更改为 .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
}
}
我使用 UINavigationController
而不是 UIViewController
:
extension UINavigationController {
open override func awakeFromNib() {
super.awakeFromNib()
navigationController?.view.semanticContentAttribute = .forceRightToLeft
navigationController?.navigationBar.semanticContentAttribute = .forceRightToLeft
}
}