更新:偶尔会出现button target点击无效。点击之后,没有push到下一个页面,同时整个页面无法点击,这个时候使用向右滑动的全屏手势,要push的页面会从右侧跟随手势出来,同时手势结束的时候,push的页面自动pop消失。
https://www.cnblogs.com/tinych/p/6927654.html
//利用运行时动态拿到系统的侧滑手势 action + target 手动创建一个全屏的pan手势,响应事件用系统的
//拿到interactivePopGestureRecognizer这个对象里面全部的属性
// var count:UInt32 = 0
// let ivars = class_copyIvarList(UIGestureRecognizer.self, &count)!
// for i in 0..<count {
// //拿到ivar指针
// let nameP = ivar_getName(ivars[Int(i)])
// //根据指针找到对应的属性的字符串
// let name = String(cString: nameP!)
// print(name)
// }
guard let targets = interactivePopGestureRecognizer?.value(forKey: "_targets") as?[AnyObject] else {
return
}
//拿到 action=handleNavigationTransition:, target=<_UINavigationInteractiveTransition 0x7ff515c0dc80>
let dict = targets[0]
//拿到action
let target = dict.value(forKey: "target") as Any
//通过字典无法拿到action,这里通过Selector方法包装action
let action = Selector(("handleNavigationTransition:"))
//拿到target action 创建pan手势并添加到全屏view上
let gesture = UIPanGestureRecognizer(target: target, action: action)
view.addGestureRecognizer(gesture)