diff --git a/FDFullscreenPopGesture/UINavigationController+FDFullscreenPopGesture.h b/FDFullscreenPopGesture/UINavigationController+FDFullscreenPopGesture.h index 1be8de7..cd39b4e 100644 --- a/FDFullscreenPopGesture/UINavigationController+FDFullscreenPopGesture.h +++ b/FDFullscreenPopGesture/UINavigationController+FDFullscreenPopGesture.h @@ -39,6 +39,10 @@ /// Default to YES, disable it if you don't want so. @property (nonatomic, assign) BOOL fd_viewControllerBasedNavigationBarAppearanceEnabled; +/// Max allowed initial distance to left edge when you begin the interactive pop +/// gesture. 0 by default, which means it will ignore this limit. +@property (nonatomic, assign) CGFloat fd_interactivePopMaxAllowedInitialDistanceToLeftEdge; + @end /// Allows any view controller to disable interactive pop gesture, which might @@ -55,8 +59,4 @@ /// Default to NO, bars are more likely to show. @property (nonatomic, assign) BOOL fd_prefersNavigationBarHidden; -/// Max allowed initial distance to left edge when you begin the interactive pop -/// gesture. 0 by default, which means it will ignore this limit. -@property (nonatomic, assign) CGFloat fd_interactivePopMaxAllowedInitialDistanceToLeftEdge; - @end diff --git a/FDFullscreenPopGesture/UINavigationController+FDFullscreenPopGesture.m b/FDFullscreenPopGesture/UINavigationController+FDFullscreenPopGesture.m index 914f217..d59a4d6 100644 --- a/FDFullscreenPopGesture/UINavigationController+FDFullscreenPopGesture.m +++ b/FDFullscreenPopGesture/UINavigationController+FDFullscreenPopGesture.m @@ -46,7 +46,7 @@ - (BOOL)gestureRecognizerShouldBegin:(UIPanGestureRecognizer *)gestureRecognizer // Ignore when the beginning location is beyond max allowed initial distance to left edge. CGPoint beginningLocation = [gestureRecognizer locationInView:gestureRecognizer.view]; - CGFloat maxAllowedInitialDistance = topViewController.fd_interactivePopMaxAllowedInitialDistanceToLeftEdge; + CGFloat maxAllowedInitialDistance = self.navigationController.fd_interactivePopMaxAllowedInitialDistanceToLeftEdge; if (maxAllowedInitialDistance > 0 && beginningLocation.x > maxAllowedInitialDistance) { return NO; } @@ -237,6 +237,21 @@ - (void)setFd_viewControllerBasedNavigationBarAppearanceEnabled:(BOOL)enabled objc_setAssociatedObject(self, key, @(enabled), OBJC_ASSOCIATION_RETAIN_NONATOMIC); } + +- (CGFloat)fd_interactivePopMaxAllowedInitialDistanceToLeftEdge +{ +#if CGFLOAT_IS_DOUBLE + return [objc_getAssociatedObject(self, _cmd) doubleValue]; +#else + return [objc_getAssociatedObject(self, _cmd) floatValue]; +#endif +} + +- (void)setFd_interactivePopMaxAllowedInitialDistanceToLeftEdge:(CGFloat)distance +{ + SEL key = @selector(fd_interactivePopMaxAllowedInitialDistanceToLeftEdge); + objc_setAssociatedObject(self, key, @(MAX(0, distance)), OBJC_ASSOCIATION_RETAIN_NONATOMIC); +} @end @implementation UIViewController (FDFullscreenPopGesture) @@ -262,19 +277,4 @@ - (void)setFd_prefersNavigationBarHidden:(BOOL)hidden } -- (CGFloat)fd_interactivePopMaxAllowedInitialDistanceToLeftEdge -{ -#if CGFLOAT_IS_DOUBLE - return [objc_getAssociatedObject(self, _cmd) doubleValue]; -#else - return [objc_getAssociatedObject(self, _cmd) floatValue]; -#endif -} - -- (void)setFd_interactivePopMaxAllowedInitialDistanceToLeftEdge:(CGFloat)distance -{ - SEL key = @selector(fd_interactivePopMaxAllowedInitialDistanceToLeftEdge); - objc_setAssociatedObject(self, key, @(MAX(0, distance)), OBJC_ASSOCIATION_RETAIN_NONATOMIC); -} - @end diff --git a/FDFullscreenPopGestureDemo/FDFullscreenPopGestureDemo/Base.lproj/Main.storyboard b/FDFullscreenPopGestureDemo/FDFullscreenPopGestureDemo/Base.lproj/Main.storyboard index 017c7a7..b7fda7d 100644 --- a/FDFullscreenPopGestureDemo/FDFullscreenPopGestureDemo/Base.lproj/Main.storyboard +++ b/FDFullscreenPopGestureDemo/FDFullscreenPopGestureDemo/Base.lproj/Main.storyboard @@ -1,8 +1,8 @@ - + - + @@ -11,18 +11,21 @@ - + + + + +