Commit 833c9dee cgx

状态栏处理(导航栏控制和页面单独控制)

1 个父辈 e2200162
...@@ -911,6 +911,7 @@ ...@@ -911,6 +911,7 @@
INFOPLIST_KEY_CFBundleDisplayName = "小梦睡眠-Dev"; INFOPLIST_KEY_CFBundleDisplayName = "小梦睡眠-Dev";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIStatusBarHidden = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 11.0; IPHONEOS_DEPLOYMENT_TARGET = 11.0;
...@@ -956,9 +957,10 @@ ...@@ -956,9 +957,10 @@
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
HEADER_SEARCH_PATHS = "$(inherited)/**"; HEADER_SEARCH_PATHS = "$(inherited)/**";
INFOPLIST_FILE = DreamSleep/DSConfig/Info.plist; INFOPLIST_FILE = DreamSleep/DSConfig/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "小梦睡眠"; INFOPLIST_KEY_CFBundleDisplayName = "小梦睡眠-Dev";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIStatusBarHidden = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 11.0; IPHONEOS_DEPLOYMENT_TARGET = 11.0;
...@@ -1062,9 +1064,10 @@ ...@@ -1062,9 +1064,10 @@
GENERATE_INFOPLIST_FILE = YES; GENERATE_INFOPLIST_FILE = YES;
HEADER_SEARCH_PATHS = "$(inherited)/**"; HEADER_SEARCH_PATHS = "$(inherited)/**";
INFOPLIST_FILE = DreamSleep/DSConfig/Info.plist; INFOPLIST_FILE = DreamSleep/DSConfig/Info.plist;
INFOPLIST_KEY_CFBundleDisplayName = "小梦睡眠-Beta"; INFOPLIST_KEY_CFBundleDisplayName = "小梦睡眠-Dev";
INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES; INFOPLIST_KEY_UIApplicationSupportsIndirectInputEvents = YES;
INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen; INFOPLIST_KEY_UILaunchStoryboardName = LaunchScreen;
INFOPLIST_KEY_UIStatusBarHidden = YES;
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPad = "UIInterfaceOrientationPortrait UIInterfaceOrientationPortraitUpsideDown UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight"; INFOPLIST_KEY_UISupportedInterfaceOrientations_iPhone = "UIInterfaceOrientationPortrait UIInterfaceOrientationLandscapeLeft UIInterfaceOrientationLandscapeRight";
IPHONEOS_DEPLOYMENT_TARGET = 11.0; IPHONEOS_DEPLOYMENT_TARGET = 11.0;
......
...@@ -12,11 +12,13 @@ ...@@ -12,11 +12,13 @@
- NaviStyleDefault: 默认 - NaviStyleDefault: 默认
- NaviStyleLight : Light - NaviStyleLight : Light
- NaviStyleDark : Dark - NaviStyleDark : Dark
- NaviStyleUndef:未定义
*/ */
typedef NS_ENUM(NSUInteger, NaviStyle) { typedef NS_ENUM(NSUInteger, NaviStyle) {
NaviStyleDefault, NaviStyleDefault,
NaviStyleLight, NaviStyleLight,
NaviStyleDark, NaviStyleDark,
NaviStyleUndef
}; };
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
......
...@@ -7,7 +7,7 @@ ...@@ -7,7 +7,7 @@
// //
#import <UIKit/UIKit.h> #import <UIKit/UIKit.h>
#import "NaviBarHandlerProtocol.h"
@interface UIViewController (Swizzling) <NaviBarHandlerProtocol> @interface UIViewController (Swizzling) <NaviBarHandlerProtocol>
@end @end
...@@ -56,7 +56,9 @@ ...@@ -56,7 +56,9 @@
[BaseNaviController setNavigationBarStyle:[self navigationBarStyle] vc:self]; [BaseNaviController setNavigationBarStyle:[self navigationBarStyle] vc:self];
} else { } else {
// 默认风格 // 默认风格
[BaseNaviController setNavigationBarStyle:NaviStyleDefault vc:self]; if (self.navigationController) {
[BaseNaviController setNavigationBarStyle:NaviStyleDefault vc:self];
}
} }
#pragma mark - 重返系统事件 #pragma mark - 重返系统事件
......
...@@ -31,5 +31,7 @@ ...@@ -31,5 +31,7 @@
<array> <array>
<string>audio</string> <string>audio</string>
</array> </array>
<key>UIStatusBarStyle</key>
<string>UIStatusBarStyleLightContent</string>
</dict> </dict>
</plist> </plist>
...@@ -16,10 +16,15 @@ ...@@ -16,10 +16,15 @@
- (void)viewDidLoad { - (void)viewDidLoad {
[super viewDidLoad]; [super viewDidLoad];
self.view = self.leadView; self.view = self.leadView;
} }
#pragma mark - 设置状态栏文字颜色
- (UIStatusBarStyle)preferredStatusBarStyle {
return [self.dk_manager.themeVersion isEqualToString:DKThemeVersionNormal] ? UIStatusBarStyleDefault : UIStatusBarStyleLightContent;
}
- (LeadView *)leadView { - (LeadView *)leadView {
if (!_leadView) { if (!_leadView) {
_leadView = [[LeadView alloc] initWithFrame:self.view.bounds]; _leadView = [[LeadView alloc] initWithFrame:self.view.bounds];
......
...@@ -22,13 +22,12 @@ ...@@ -22,13 +22,12 @@
self.window.backgroundColor = DSWhite; self.window.backgroundColor = DSWhite;
[self.window makeKeyAndVisible]; [self.window makeKeyAndVisible];
UIStoryboard * mainStoryBoard =[UIStoryboard storyboardWithName:@"Main" bundle:nil]; UIStoryboard * mainStoryBoard =[UIStoryboard storyboardWithName:@"Main" bundle:nil];
self.window.rootViewController = [mainStoryBoard instantiateViewControllerWithIdentifier:@"mainSB"]; // self.window.rootViewController = [mainStoryBoard instantiateViewControllerWithIdentifier:@"mainSB"];
// BaseNaviController *navi = [[BaseNaviController alloc] initWithRootViewController:[[PrivacyViewController alloc] init]]; BaseNaviController *navi = [[BaseNaviController alloc] initWithRootViewController:[[PrivacyViewController alloc] init]];
// self.window.rootViewController = navi; self.window.rootViewController = navi;
[self initWeChat]; [self initWeChat];
[self initYTKNetwork];
return YES; return YES;
} }
...@@ -48,10 +47,6 @@ ...@@ -48,10 +47,6 @@
// }]; // }];
} }
- (void)initYTKNetwork {
}
- (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options { - (BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey, id> *)options {
return [WXApi handleOpenURL:url delegate:self]; return [WXApi handleOpenURL:url delegate:self];
} }
......
...@@ -38,10 +38,12 @@ ...@@ -38,10 +38,12 @@
titleColor = ColorFromHex(0x333333); titleColor = ColorFromHex(0x333333);
bgColor = DSWhite; bgColor = DSWhite;
barTintColor = DSWhite; barTintColor = DSWhite;
// naviBar.barStyle = UIBarStyleDefault;
} else if (style == NaviStyleDark) { } else if (style == NaviStyleDark) {
titleColor = DSWhite; titleColor = DSWhite;
bgColor = DarkColor; bgColor = DarkColor;
barTintColor = DarkColor; barTintColor = DarkColor;
// naviBar.barStyle = UIBarStyleBlack;
} }
// 设置导航栏title颜色、导航栏背景色、隐藏分割线 // 设置导航栏title颜色、导航栏背景色、隐藏分割线
...@@ -71,4 +73,31 @@ ...@@ -71,4 +73,31 @@
} }
} }
/*
状态栏风格设置:
1、如果UIViewController由导航控制器管理,则状态栏风格由导航栏preferredStatusBarStyle决定;
2、如果UIViewController没有由导航控制器管理,则需要单独在控制器种进行设置
//#pragma mark - 设置状态栏文字颜色
//- (UIStatusBarStyle)preferredStatusBarStyle {
// return UIStatusBarStyleLightContent;
//}
//#pragma mark - 隐藏状态栏
//- (BOOL)prefersStatusBarHidden {
// return YES;
//}
*/
- (UIStatusBarStyle)preferredStatusBarStyle {
// 白天和黑夜2种模式
UIStatusBarStyle barStyle = [self.dk_manager.themeVersion isEqualToString:DKThemeVersionNormal] ? UIStatusBarStyleDefault : UIStatusBarStyleLightContent;
// 默认风格模式(控制器重写navigationBarStyle方法)
UIViewController* topVC = self.topViewController;
if ([topVC respondsToSelector:@selector(navigationBarStyle)]) {
NaviStyle sty = (NaviStyle)[topVC performSelector:@selector(navigationBarStyle)];
if (sty == NaviStyleDefault) { barStyle = UIStatusBarStyleLightContent; }
}
return barStyle;
}
@end @end
...@@ -63,6 +63,21 @@ ...@@ -63,6 +63,21 @@
return NO; return NO;
} }
#pragma mark - H5页面导航栏为默认模式
- (NaviStyle)navigationBarStyle {
return self.isDetail ? NaviStyleDefault : NaviStyleUndef;
}
#pragma mark - 设置状态栏文字颜色
- (UIStatusBarStyle)preferredStatusBarStyle {
if (self.isDetail) {
// 导航栏显示不会执行以下代码
return UIStatusBarStyleLightContent;
} else {
return [self.dk_manager.themeVersion isEqualToString:DKThemeVersionNormal] ? UIStatusBarStyleDefault : UIStatusBarStyleLightContent;
}
}
- (void)showPrivacyView { - (void)showPrivacyView {
self.policyView = [[PrivacyView alloc] init]; self.policyView = [[PrivacyView alloc] init];
[self.view addSubview:self.policyView]; [self.view addSubview:self.policyView];
......
...@@ -23,7 +23,7 @@ ...@@ -23,7 +23,7 @@
self.tmpDatas = @[@"注册登录信息", @"意见反馈", @"系统设置", @"邀请好友", @"关于我们", @"前往小程序", @"关注公众号", @"添加客服微信", @"失眠的认知行为疗法", @"模拟Apple登录"]; self.tmpDatas = @[@"注册登录信息", @"意见反馈", @"系统设置", @"邀请好友", @"关于我们", @"前往小程序", @"关注公众号", @"添加客服微信", @"失眠的认知行为疗法", @"模拟Apple登录"];
} }
#pragma mark - 导航栏日间、黑夜模式 #pragma mark - 导航栏默认模式
- (NaviStyle)navigationBarStyle { - (NaviStyle)navigationBarStyle {
return NaviStyleDefault; return NaviStyleDefault;
} }
......
支持 Markdown 格式
你添加了 0 到此讨论。请谨慎行事。
Finish editing this message first!