使用 AOP 在 iOS14+ 系统风格中实现全屏弹出手势。
整体实现参照 FDFullscreenPopGesture
对外暴露的属性保持一致
public protocol PopGestureRecognizable: AnyObject {
var interactivePopDisabled: Bool { get set }
var prefersNavigationBarHidden: Bool { get set }
var interactivePopMaxAllowedInitialDistanceToLeftEdge: CGFloat { get set }
var willAppearInjectBlock: ((_ viewController: UIViewController, _ animated: Bool) -> Void)? { get set }
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool
}
AOP,只需添加 2 个文件,无需进行任何设置,所有导航控制器将能够自动使用全屏弹出手势。
要禁用导航控制器的此弹出手势
navigationController?.fullscreenPopGestureRecognizer.isEnabled = false
要禁用视图控制器的此弹出手势
interactivePopDisabled = false
FullScreenPopGesture 通过 CocoaPods 提供。要安装它,只需将以下行添加到您的 Podfile 中
pod 'FSPopGesture'
booniez, [email protected]
FullScreenPopGesture 在 MIT 许可证下可用。有关更多信息,请参阅 LICENSE 文件。