Commit ecff3739 cgx

解决UIImagePickerController导航透明问题

1 个父辈 d8bd551b
......@@ -9,7 +9,6 @@
#import "UIViewController+Swizzling.h"
#import "BaseNaviController.h"
#import <objc/runtime.h>
#import "JWMImagePickerController.h"
@implementation UIViewController (Swizzling)
......@@ -53,22 +52,15 @@
self.navigationController.navigationBarHidden = ([self respondsToSelector:@selector(isShowNavigationBar)] && [self isShowNavigationBar] == YES) ? YES : NO;
#pragma mark - 根据不同页面设置不同的导航栏风格
NSString *className = NSStringFromClass([self class]);
NSArray *classArrary = @[@"JWMImagePickerController",
@"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 - 处理用户打开自动切换主题按钮,根据设定好的时间段进行主题切换
if (kGetUserDefaultsBOOL(ThemeAutoSwitch)) {
......
......@@ -20,4 +20,18 @@
// 加载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
......@@ -29,6 +29,27 @@
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 {
UIImage *editedImage = [info objectForKey:UIImagePickerControllerOriginalImage];
[picker dismissViewControllerAnimated:YES completion:nil];
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!