Commit ecff3739 cgx

解决UIImagePickerController导航透明问题

1 个父辈 d8bd551b
...@@ -9,7 +9,6 @@ ...@@ -9,7 +9,6 @@
#import "UIViewController+Swizzling.h" #import "UIViewController+Swizzling.h"
#import "BaseNaviController.h" #import "BaseNaviController.h"
#import <objc/runtime.h> #import <objc/runtime.h>
#import "JWMImagePickerController.h"
@implementation UIViewController (Swizzling) @implementation UIViewController (Swizzling)
...@@ -53,22 +52,15 @@ ...@@ -53,22 +52,15 @@
self.navigationController.navigationBarHidden = ([self respondsToSelector:@selector(isShowNavigationBar)] && [self isShowNavigationBar] == YES) ? YES : NO; self.navigationController.navigationBarHidden = ([self respondsToSelector:@selector(isShowNavigationBar)] && [self isShowNavigationBar] == YES) ? YES : NO;
#pragma mark - 根据不同页面设置不同的导航栏风格 #pragma mark - 根据不同页面设置不同的导航栏风格
NSString *className = NSStringFromClass([self class]); if ([self respondsToSelector:@selector(navigationBarStyle)]) {
NSArray *classArrary = @[@"JWMImagePickerController", [BaseNaviController setNavigationBarStyle:[self navigationBarStyle] vc:self];
@"CAMImagePickerCameraViewController", @"CAMViewfinderViewController", @"CAMPreviewViewController",
@"UIInputWindowController", @"UIEditingOverlayViewController", @"PUPhotoPickerHostViewController",
@"PLPhotoTileViewController"];
// 排除系统相机和相册
if (![classArrary containsObject:className]) {
if ([self respondsToSelector:@selector(navigationBarStyle)]) {
[BaseNaviController setNavigationBarStyle:[self navigationBarStyle] vc:self];
} else {
// 默认风格
if (self.navigationController) {
[BaseNaviController setNavigationBarStyle:NaviStyleDefault vc:self];
}
}
} }
// 系统拍照和相册页面调试
// NSString *className = NSStringFromClass([self class]);
// NSArray *classArrary = @[@"JWMImagePickerController",
// @"CAMImagePickerCameraViewController", @"CAMViewfinderViewController", @"CAMPreviewViewController",
// @"UIInputWindowController", @"UIEditingOverlayViewController", @"PUPhotoPickerHostViewController",
// @"PLPhotoTileViewController"];
#pragma mark - 处理用户打开自动切换主题按钮,根据设定好的时间段进行主题切换 #pragma mark - 处理用户打开自动切换主题按钮,根据设定好的时间段进行主题切换
if (kGetUserDefaultsBOOL(ThemeAutoSwitch)) { if (kGetUserDefaultsBOOL(ThemeAutoSwitch)) {
......
...@@ -14,10 +14,24 @@ ...@@ -14,10 +14,24 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.view.backgroundColor = DSWhite; self.view.backgroundColor = DSWhite;
// 加载unity // 加载unity
} }
- (void)touchesBegan:(NSSet<UITouch *> *)touches withEvent:(UIEvent *)event {
[self.navigationController popViewControllerAnimated:YES];
}
#pragma mark - 隐藏导航栏
- (BOOL)isShowNavigationBar {
return YES;
}
#pragma mark - 设置状态栏文字颜色
- (UIStatusBarStyle)preferredStatusBarStyle {
return UIStatusBarStyleLightContent;
}
@end @end
...@@ -29,6 +29,27 @@ ...@@ -29,6 +29,27 @@
return self; return self;
} }
#pragma mark - 解决UIImagePickerController导航透明问题
- (void)navigationController:(UINavigationController *)navigationController
willShowViewController:(UIViewController *)viewController
animated:(BOOL)animated
{
if ([navigationController isKindOfClass:[UIImagePickerController class]]) {
self.navigationBarHidden = YES;
if (@available(iOS 13.0, *)) {
UINavigationBarAppearance *appearance = [UINavigationBarAppearance new];
// 导航栏背景色
appearance.backgroundColor = DSBlack;
// 隐藏分割线
appearance.shadowColor = DSClearColor;
// 生效
self.navigationBar.scrollEdgeAppearance = appearance;
// 滚动视图滚动后导航栏背景色不会被影响
self.navigationBar.standardAppearance = appearance;
}
}
}
- (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info { - (void)imagePickerController:(UIImagePickerController *)picker didFinishPickingMediaWithInfo:(NSDictionary<NSString *,id> *)info {
UIImage *editedImage = [info objectForKey:UIImagePickerControllerOriginalImage]; UIImage *editedImage = [info objectForKey:UIImagePickerControllerOriginalImage];
[picker dismissViewControllerAnimated:YES completion:nil]; [picker dismissViewControllerAnimated:YES completion:nil];
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!