DSNaviBarViewController.m
3.2 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//
// DSNaviBarViewController.m
// DreamSleep
//
// Created by peter on 2022/5/19.
//
#import "DSNaviBarViewController.h"
@interface DSNaviBarViewController ()
@end
@implementation DSNaviBarViewController
- (void)viewDidLoad {
[super viewDidLoad];
[self.view insertSubview:self.dsNaviBar atIndex:99];
}
- (void)setNaviTitle:(NSString *)naviTitle {
_naviTitle = naviTitle;
self.titleLab.text = _naviTitle;
}
- (void)setNaviBarAlpha:(CGFloat)naviBarAlpha {
_naviBarAlpha = naviBarAlpha;
self.dsNaviBar.alpha = _naviBarAlpha;
}
- (void)setIsNeedUpdateStatusBarStyle:(BOOL)isNeedUpdateStatusBarStyle {
_isNeedUpdateStatusBarStyle = isNeedUpdateStatusBarStyle;
// 手动调用更新状态栏
[self setNeedsStatusBarAppearanceUpdate];
}
- (void)setNaviBgColor:(UIColor *)naviBgColor {
_naviBgColor = naviBgColor;
self.dsNaviBar.backgroundColor = naviBgColor;
}
#pragma mark - 隐藏系统导航栏
- (BOOL)isHideNavigationBar {
return YES;
}
#pragma mark - 设置状态栏文字颜色
- (UIStatusBarStyle)preferredStatusBarStyle {
if (self.isNeedUpdateStatusBarStyle) {
return UIStatusBarStyleLightContent;
}
return [self.dk_manager.themeVersion isEqualToString:DKThemeVersionNormal] ? UIStatusBarStyleDefault : UIStatusBarStyleLightContent;
}
//#pragma mark - 导航栏日间、黑夜模式
//- (NaviStyle)navigationBarStyle {
// // 我的界面需要对用户是否打开自动切换进行处理
// if (kGetUserDefaultsBOOL(ThemeAutoSwitch)) {
// return ([NSDate judgeTimeWithStartTime:StartTime1 expireTime:ExpireTime1] || [NSDate judgeTimeWithStartTime:StartTime2 expireTime:ExpireTime2]) ? NaviStyleDark : NaviStyleLight;
// } else {
// return [self.dk_manager.themeVersion isEqualToString:DKThemeVersionNormal] ? NaviStyleLight : NaviStyleDark;
// }
//}
- (void)backAction {
if (self.navigationController.viewControllers.count > 0) {
[self.navigationController popViewControllerAnimated:YES];
}
}
#pragma mark - lazy
- (UIView *)dsNaviBar {
if (!_dsNaviBar) {
_dsNaviBar = [[UIView alloc] initWithFrame:CGRectMake(0, 0, kScreenWidth, kTopHeight(0))];
_dsNaviBar.alpha = 0;
_dsNaviBar.dk_backgroundColorPicker = DKColorPickerWithColors(BrandColor, DarkColor, DSWhite);
[_dsNaviBar addSubview:self.titleLab];
[_titleLab mas_makeConstraints:^(MASConstraintMaker *make) {
make.centerX.equalTo(self.dsNaviBar);
make.bottom.equalTo(self.dsNaviBar).offset(-9);
}];
}
return _dsNaviBar;
}
- (UILabel *)titleLab {
if (!_titleLab) {
_titleLab = [UILabel labWithTextColor:DSWhite font:BoldFont(18)];
_titleLab.textAlignment = NSTextAlignmentCenter;
}
return _titleLab;
}
- (UIButton *)backBtn {
if (!_backBtn) {
_backBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, kStatusBarHeight, 40, 40)];
[_backBtn dk_setImage:DKImagePickerWithNames(@"cus_back_icon", @"dk_cus_back_icon", @"dk_cus_back_icon") forState:UIControlStateNormal];
[_backBtn addTarget:self action:@selector(backAction) forControlEvents:UIControlEventTouchUpInside];
}
return _backBtn;
}
@end