SJNavigationPopGesture 1.4.8

SJNavigationPopGesture 1.4.8

changsanjiang 维护。



  • SanJiang

SJFullscreenPopGesture

全屏返回手势。非常适合视频播放器应用。
全屏返回手势。非常适合带有视频播放器的App。

Objective-C

pod 'SJFullscreenPopGesture'

Swift

pod 'SJNavigationPopGesture'
// and install
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    // you need call it
    // app 启动的时候, 需要调用这个方法
    
    SJNavigationPopGesture.install()

    // ...

    return true
}

特性

  • 全屏返回手势。手势在 UIScrollView 和 UIPageViewController 中被完美处理。
  • 淡入区域。指定的区域不会触发手势。不会影响其他 ViewControllers。
  • 禁用手势。指定 ViewController 禁用返回手势。不会影响其他 ViewControllers。
  • WKWebView。

示例

  • _

  • WKWebView

请等待示例加载,或直接下载项目。


禁用手势

// If you want to disable the gestures, you can do the same as below. It does not affect other ViewControllers.
// 1. `import header`
#import "UIViewController+SJVideoPlayerAdd.h"
- (void)viewDidLoad {
    [super viewDidLoad];
    // 2. `set this property`
    self.sj_DisableGestures = YES; // 如果想在某个页面禁用全屏手势, 可以这样做. 不影响其他页面. 离开页面时, 也无需恢复.
}

考虑 WKWebView

// 1. `import header`
#import "UIViewController+SJVideoPlayerAdd.h"
- (void)viewDidLoad {
    [super viewDidLoad];
    // 2. `set this property`
    self.sj_considerWebView = self.webView; // when this property is set, will be enabled system gesture to back last web page, until it can't go back. 当设置这个属性后, 将会开启右滑返回上一个网页的手势. 最后才会触发全局pop手势.
}

渐变区

// If you want an area to not trigger gestures, you can do the same as below. It does not affect other ViewControllers.
// 1. `import header`
#import "UIViewController+SJVideoPlayerAdd.h"
- (void)viewDidLoad {
    [super viewDidLoad];
    
    // 2. `set this property`
    self.sj_fadeAreaViews = @[_btn, _view2]; // 如果想某个区域不触发手势, 可以这样做.
    // or
    self.sj_fadeArea = @[@(_btn.frame), @(_view2.frame)]; // 如果想某个区域不触发手势, 可以这样做.
}

常用方法

@interface UIViewController (SJVideoPlayerAdd)

@property (nonatomic, readonly) UIGestureRecognizerState sj_fullscreenGestureState;

@property (nonatomic, weak, readwrite, nullable) WKWebView *sj_considerWebView;

@property (nonatomic, strong, readwrite, nullable) NSArray<NSValue *> *sj_fadeArea;

@property (nonatomic, strong, readwrite, nullable) NSArray<UIView *> *sj_fadeAreaViews;

@property (nonatomic, assign, readwrite) BOOL sj_DisableGestures;

@property (nonatomic, copy, readwrite, nullable) void(^sj_viewWillBeginDragging)(__kindof UIViewController *vc);

@property (nonatomic, copy, readwrite, nullable) void(^sj_viewDidDrag)(__kindof UIViewController *vc);

@property (nonatomic, copy, readwrite, nullable) void(^sj_viewDidEndDragging)(__kindof UIViewController *vc);

@end

联系

授权

SJFullscreenPopGesture 在 MIT 许可协议下可用。有关更多信息,请参阅 LICENSE 文件。