抄自github-issues,实测好用 新建UIViewController+ZFPlayerFixSafeArea 文件,复制代码,运行~~~
#import <objc/message.h>
#import <ZFPlayer/ZFPlayerController.h>
BOOL zf_isFullscreenOfFixSafeArea = NO;
API_AVAILABLE(ios(13.0)) @protocol _UIViewControllerPrivateMethodsProtocol <NSObject>
- (void)_setContentOverlayInsets:(UIEdgeInsets)insets andLeftMargin:(CGFloat)leftMargin rightMargin:(CGFloat)rightMargin;
@end
@implementationUIViewController (ZFPlayerFixSafeArea)
- (void)zf_setContentOverlayInsets:(UIEdgeInsets)insetsandLeftMargin:(CGFloat)leftMarginrightMargin:(CGFloat)rightMargin {
if (zf_isFullscreenOfFixSafeArea == NO) {
[self zf_setContentOverlayInsets:insets andLeftMargin:leftMargin rightMargin:rightMargin];
}
}
@end
API_AVAILABLE(ios(13.0))@implementationZFOrientationObserver (ZFPlayerFixSafeArea)
+ (void)initialize {
if(@available(iOS13.0, *) ) {
staticdispatch_once_tonceToken;
dispatch_once(&onceToken, ^{
Classcls =UIViewController.class;
SELoriginalSelector =@selector(_setContentOverlayInsets:andLeftMargin:rightMargin:);
SELswizzledSelector =@selector(zf_setContentOverlayInsets:andLeftMargin:rightMargin:);
MethodoriginalMethod =class_getInstanceMethod(cls, originalSelector);
MethodswizzledMethod =class_getInstanceMethod(cls, swizzledSelector);
method_exchangeImplementations(originalMethod, swizzledMethod);
Classpc_class =ZFPlayerController.class;
SELpc_originalSelector =@selector(enterFullScreen:animated:completion:);
#pragma clang diagnostic push
#pragma clang diagnostic ignored"-Wundeclared-selector"
SELpc_swizzledSelector =@selector(zf_enterFullScreen:animated:completion:);
#pragma clang diagnostic pop
Methodpc_originalMethod =class_getInstanceMethod(pc_class, pc_originalSelector);
Methodpc_swizzledMethod =class_getInstanceMethod(pc_class, pc_swizzledSelector);
method_exchangeImplementations(pc_originalMethod, pc_swizzledMethod);
});
}
}
@end
API_AVAILABLE(ios(13.0))@implementationZFPlayerController(ZFPlayerFixSafeArea)
- (void)zf_enterFullScreen:(BOOL)fullScreenanimated:(BOOL)animatedcompletion:(void(^_Nullable)(void))completion {
zf_isFullscreenOfFixSafeArea = fullScreen;
[selfzf_enterFullScreen:fullScreenanimated:animatedcompletion:completion];
}
@end
网友评论