Skip to content

Commit b49a958

Browse files
committed
优化升级,release 3.0.2
1 parent 1447c68 commit b49a958

File tree

114 files changed

+326
-191
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+326
-191
lines changed

GKNavigationBarViewController.podspec

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
Pod::Spec.new do |s|
22
s.name = "GKNavigationBarViewController"
3-
s.version = "3.0.1"
3+
s.version = "3.0.2"
44
s.summary = "自定义导航栏--导航栏联动"
55
s.homepage = "https://github.com/QuintGao/GKNavigationBarViewController"
66
s.license = "MIT"
7-
s.authors = { "高坤" => "1094887059@qq.com" }
7+
s.authors = { "QuintGao" => "1094887059@qq.com" }
88
s.social_media_url = "https://github.com/QuintGao"
99
s.platform = :ios, "9.0"
1010
s.ios.deployment_target = "9.0"

GKNavigationBarViewController/GKCategory/GKCategory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// GKNavigationBarViewController
44
//
55
// Created by QuintGao on 2017/8/31.
6-
// Copyright © 2017年 高坤. All rights reserved.
6+
// Copyright © 2017年 QuintGao. All rights reserved.
77
//
88

99
#ifndef GKCategory_h

GKNavigationBarViewController/GKCategory/UIBarButtonItem+GKCategory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// GKNavigationBarViewController
44
//
55
// Created by QuintGao on 2017/7/7.
6-
// Copyright © 2017年 高坤. All rights reserved.
6+
// Copyright © 2017年 QuintGao. All rights reserved.
77
//
88

99
#import <UIKit/UIKit.h>

GKNavigationBarViewController/GKCategory/UIBarButtonItem+GKCategory.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// GKNavigationBarViewController
44
//
55
// Created by QuintGao on 2017/7/7.
6-
// Copyright © 2017年 高坤. All rights reserved.
6+
// Copyright © 2017年 QuintGao. All rights reserved.
77
//
88

99
#import "UIBarButtonItem+GKCategory.h"

GKNavigationBarViewController/GKCategory/UIImage+GKCategory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
// UIImage+GKCategory.h
33
// GKNavigationBar
44
//
5-
// Created by gaokun on 2019/11/1.
5+
// Created by QuintGao on 2019/11/1.
66
// Copyright © 2019 QuintGao. All rights reserved.
77
//
88

GKNavigationBarViewController/GKCategory/UIImage+GKCategory.m

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,18 @@
22
// UIImage+GKCategory.m
33
// GKNavigationBar
44
//
5-
// Created by gaokun on 2019/11/1.
5+
// Created by QuintGao on 2019/11/1.
66
// Copyright © 2019 QuintGao. All rights reserved.
77
//
88

99
#import "UIImage+GKCategory.h"
10+
#import "GKNavigationBarConfigure.h"
1011

1112
@implementation UIImage (GKCategory)
1213

1314
+ (UIImage *)gk_imageNamed:(NSString *)name {
14-
NSString *bundleName = [@"GKNavigationBarViewController.bundle" stringByAppendingPathComponent:name];
15-
NSString *frameWorkName = [@"Frameworks/GKNavigationBarViewController.framework/GKNavigationBarViewController.bundle" stringByAppendingPathComponent:name];
16-
17-
UIImage *image = [UIImage imageNamed:bundleName] ?: [UIImage imageNamed:frameWorkName];
15+
if (![GKConfigure gk_libraryBundle]) return [UIImage imageNamed:name];
16+
UIImage *image = [UIImage imageNamed:name inBundle:[GKConfigure gk_libraryBundle] compatibleWithTraitCollection:nil];
1817
if (!image) image = [UIImage imageNamed:name];
1918
return image;
2019
}

GKNavigationBarViewController/GKCategory/UINavigationController+GKCategory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// GKNavigationBarViewController
44
//
55
// Created by QuintGao on 2017/7/7.
6-
// Copyright © 2017年 高坤. All rights reserved.
6+
// Copyright © 2017年 QuintGao. All rights reserved.
77
//
88

99
#import <UIKit/UIKit.h>

GKNavigationBarViewController/GKCategory/UINavigationController+GKCategory.m

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// GKNavigationBarViewController
44
//
55
// Created by QuintGao on 2017/7/7.
6-
// Copyright © 2017年 高坤. All rights reserved.
6+
// Copyright © 2017年 QuintGao. All rights reserved.
77
//
88

99
#import "UINavigationController+GKCategory.h"
@@ -118,6 +118,8 @@ - (void)handleNotification:(NSNotification *)notify {
118118
if ([vc isKindOfClass:[UITabBarController class]]) return;
119119
if (!vc.navigationController) return;
120120
if (vc.navigationController != self) return;
121+
// 修复非导航栏控制器子类时出现的问题
122+
if (vc.parentViewController != self) return;
121123

122124
__block BOOL exist = NO;
123125
[GKConfigure.shiledGuestureVCs enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {

GKNavigationBarViewController/GKCategory/UINavigationItem+GKCategory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// GKNavigationBarViewController
44
//
55
// Created by QuintGao on 2017/10/13.
6-
// Copyright © 2017年 高坤. All rights reserved.
6+
// Copyright © 2017年 QuintGao. All rights reserved.
77
//
88

99
#import <UIKit/UIKit.h>

GKNavigationBarViewController/GKCategory/UINavigationItem+GKCategory.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// GKNavigationBarViewController
44
//
55
// Created by QuintGao on 2017/10/13.
6-
// Copyright © 2017年 高坤. All rights reserved.
6+
// Copyright © 2017年 QuintGao. All rights reserved.
77
//
88

99
#import "UINavigationItem+GKCategory.h"

GKNavigationBarViewController/GKCategory/UIScrollView+GKCategory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// GKNavigationBarViewController
44
//
55
// Created by QuintGao on 2017/7/11.
6-
// Copyright © 2017年 高坤. All rights reserved.
6+
// Copyright © 2017年 QuintGao. All rights reserved.
77
//
88

99
#import <UIKit/UIKit.h>

GKNavigationBarViewController/GKCategory/UIScrollView+GKCategory.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// GKNavigationBarViewController
44
//
55
// Created by QuintGao on 2017/7/11.
6-
// Copyright © 2017年 高坤. All rights reserved.
6+
// Copyright © 2017年 QuintGao. All rights reserved.
77
//
88

99
#import "UIScrollView+GKCategory.h"

GKNavigationBarViewController/GKCategory/UIViewController+GKCategory.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// GKNavigationBarViewController
44
//
55
// Created by QuintGao on 2017/7/7.
6-
// Copyright © 2017年 高坤. All rights reserved.
6+
// Copyright © 2017年 QuintGao. All rights reserved.
77
// 使用运行时为UIViewController添加分类
88

99
#import <UIKit/UIKit.h>

GKNavigationBarViewController/GKCategory/UIViewController+GKCategory.m

Lines changed: 29 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// GKNavigationBarViewController
44
//
55
// Created by QuintGao on 2017/7/7.
6-
// Copyright © 2017年 高坤. All rights reserved.
6+
// Copyright © 2017年 QuintGao. All rights reserved.
77
//
88

99
#import "UIViewController+GKCategory.h"
@@ -210,10 +210,18 @@ + (void)load {
210210
}
211211

212212
- (void)gk_viewDidLoad {
213-
// 初始化导航栏间距
214-
self.gk_navItemLeftSpace = GKNavigationBarItemSpace;
215-
self.gk_navItemRightSpace = GKNavigationBarItemSpace;
216-
self.gk_disableFixNavItemSpace = [self checkFixNavItemSpace];
213+
if ([self navItemSpaceChangeIfNeeded]) {
214+
// 设置默认导航栏间距
215+
self.gk_navItemLeftSpace = GKNavigationBarItemSpace;
216+
self.gk_navItemRightSpace = GKNavigationBarItemSpace;
217+
self.gk_disableFixNavItemSpace = [self checkFixNavItemSpace];
218+
}
219+
// 如果是根控制器,取消返回按钮
220+
if (self.navigationController && self.navigationController.childViewControllers.count <= 1) {
221+
if ([self isKindOfClass:[GKNavigationBarViewController class]]) {
222+
((GKNavigationBarViewController *)self).gk_navLeftBarButtonItem = nil;
223+
}
224+
}
217225
[self gk_viewDidLoad];
218226
}
219227

@@ -227,14 +235,22 @@ - (void)gk_viewWillAppear:(BOOL)animated {
227235
if (!self.navigationController) return;
228236

229237
// bug fix:#41
230-
if (!self.gk_disableFixNavItemSpace) {
238+
if ([self navItemSpaceChangeIfNeeded] && !self.gk_disableFixNavItemSpace) {
231239
// 每次控制器出现的时候重置导航栏间距
232240
if (self.gk_navItemLeftSpace == GKNavigationBarItemSpace) {
233241
self.gk_navItemLeftSpace = GKConfigure.navItemLeftSpace;
242+
}else {
243+
[GKConfigure updateConfigure:^(GKNavigationBarConfigure *configure) {
244+
configure.gk_navItemLeftSpace = self.gk_navItemLeftSpace;
245+
}];
234246
}
235247

236248
if (self.gk_navItemRightSpace == GKNavigationBarItemSpace) {
237249
self.gk_navItemRightSpace = GKConfigure.navItemRightSpace;
250+
}else {
251+
[GKConfigure updateConfigure:^(GKNavigationBarConfigure *configure) {
252+
configure.gk_navItemRightSpace = self.gk_navItemRightSpace;
253+
}];
238254
}
239255
}
240256

@@ -399,6 +415,13 @@ - (BOOL)checkFixNavItemSpace {
399415
return exist;
400416
}
401417

418+
- (BOOL)navItemSpaceChangeIfNeeded {
419+
if ([self isKindOfClass:[GKNavigationBarViewController class]]) {
420+
return YES;
421+
}
422+
return [self.parentViewController isKindOfClass:[UINavigationController class]];
423+
}
424+
402425
- (void)setNavBarAlpha:(CGFloat)alpha {
403426
UINavigationBar *navBar = nil;
404427
if ([self isKindOfClass:[GKNavigationBarViewController class]]) {

GKNavigationBarViewController/GKConfigure/GKCommon.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// GKNavigationBarViewController
44
//
55
// Created by QuintGao on 2017/10/13.
6-
// Copyright © 2017年 高坤. All rights reserved.
6+
// Copyright © 2017年 QuintGao. All rights reserved.
77
// 一些公共的方法、宏定义、枚举等
88

99
#ifndef GKCommon_h
@@ -37,10 +37,12 @@
3737
#define GK_STATUSBAR_HEIGHT [GKNavigationBarConfigure statusBarFrame].size.height
3838
// 导航栏高度
3939
#define GK_NAVBAR_HEIGHT [GKNavigationBarConfigure navBarHeight]
40+
// 非全屏导航栏高度
41+
#define GK_NAVBAR_HEIGHT_NFS [GKNavigationBarConfigure navBarHeight_nonFullScreen]
4042
// 状态栏+导航栏高度
4143
#define GK_STATUSBAR_NAVBAR_HEIGHT (GK_STATUSBAR_HEIGHT + GK_NAVBAR_HEIGHT)
4244
// tabbar高度
43-
#define GK_TABBAR_HEIGHT (GK_SAFEAREA_BTM + 49.0f)
45+
#define GK_TABBAR_HEIGHT [GKNavigationBarConfigure tabBarHeight]
4446

4547
// 导航栏间距,用于不同控制器之间的间距
4648
static const CGFloat GKNavigationBarItemSpace = -1;

GKNavigationBarViewController/GKConfigure/GKNavigationBar.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// GKNavigationBarViewController
44
//
55
// Created by QuintGao on 2017/9/20.
6-
// Copyright © 2017年 高坤. All rights reserved.
6+
// Copyright © 2017年 QuintGao. All rights reserved.
77
// 自定义的导航条
88

99
#import <UIKit/UIKit.h>
@@ -13,8 +13,10 @@
1313
/** 导航栏背景色透明度,默认是1.0 */
1414
@property (nonatomic, assign) CGFloat gk_navBarBackgroundAlpha;
1515

16+
// 导航栏分割线是否隐藏
1617
@property (nonatomic, assign) BOOL gk_navLineHidden;
1718

18-
- (void)gk_navLineHideOrShow;
19+
// 在非全屏模式下显示
20+
@property (nonatomic, assign) BOOL gk_nonFullScreen;
1921

2022
@end

GKNavigationBarViewController/GKConfigure/GKNavigationBar.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// GKNavigationBarViewController
44
//
55
// Created by QuintGao on 2017/9/20.
6-
// Copyright © 2017年 高坤. All rights reserved.
6+
// Copyright © 2017年 QuintGao. All rights reserved.
77
//
88

99
#import "GKNavigationBar.h"
@@ -32,7 +32,7 @@ - (void)layoutSubviews {
3232
obj.frame = frame;
3333
}else {
3434
CGRect frame = obj.frame;
35-
frame.origin.y = self.frame.size.height - GK_NAVBAR_HEIGHT;
35+
frame.origin.y = self.frame.size.height - (self.gk_nonFullScreen ? GK_NAVBAR_HEIGHT_NFS : GK_NAVBAR_HEIGHT);
3636
obj.frame = frame;
3737
}
3838
}];

GKNavigationBarViewController/GKConfigure/GKNavigationBarConfigure.h

Lines changed: 46 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
// GKNavigationBarViewController
44
//
55
// Created by QuintGao on 2017/7/10.
6-
// Copyright © 2017年 高坤. All rights reserved.
6+
// Copyright © 2017年 QuintGao. All rights reserved.
77
//
88

99
#import <UIKit/UIKit.h>
@@ -94,6 +94,9 @@
9494
/// 获取当前item修复间距
9595
- (CGFloat)gk_fixedSpace;
9696

97+
/// 获取bundle
98+
- (NSBundle *)gk_libraryBundle;
99+
97100
/// 判断当前速度是是否在敏感度范围
98101
/// @param velocity 速度
99102
- (BOOL)isVelocityInSensitivity:(CGFloat)velocity;
@@ -116,61 +119,66 @@
116119
@property (class, nonatomic, readonly) BOOL isRegularScreen;
117120

118121
/// iPhone 12 Pro Max
119-
@property(class, nonatomic, readonly) BOOL is67InchScreen;
122+
@property (class, nonatomic, readonly) BOOL is67InchScreen;
120123

121124
/// iPhone XS Max / 11 Pro Max
122-
@property(class, nonatomic, readonly) BOOL is65InchScreen;
125+
@property (class, nonatomic, readonly) BOOL is65InchScreen;
123126

124127
/// iPhone 12 / 12 Pro
125-
@property(class, nonatomic, readonly) BOOL is61InchScreenAndiPhone12;
128+
@property (class, nonatomic, readonly) BOOL is61InchScreenAndiPhone12;
126129

127130
/// iPhone XR / 11
128-
@property(class, nonatomic, readonly) BOOL is61InchScreen;
131+
@property (class, nonatomic, readonly) BOOL is61InchScreen;
129132

130133
/// iPhone X / XS / 11Pro
131-
@property(class, nonatomic, readonly) BOOL is58InchScreen;
134+
@property (class, nonatomic, readonly) BOOL is58InchScreen;
132135

133136
/// iPhone 6,6s,7,8 Plus
134-
@property(class, nonatomic, readonly) BOOL is55InchScreen;
137+
@property (class, nonatomic, readonly) BOOL is55InchScreen;
135138

136139
/// iPhone 12 mini
137-
@property(class, nonatomic, readonly) BOOL is54InchScreen;
140+
@property (class, nonatomic, readonly) BOOL is54InchScreen;
138141

139142
/// iPhone 6,6s,7,8,SE2
140-
@property(class, nonatomic, readonly) BOOL is47InchScreen;
143+
@property (class, nonatomic, readonly) BOOL is47InchScreen;
141144

142145
/// iPhone 5,5s,5c,SE
143-
@property(class, nonatomic, readonly) BOOL is40InchScreen;
146+
@property (class, nonatomic, readonly) BOOL is40InchScreen;
144147

145148
/// iPhone 4
146-
@property(class, nonatomic, readonly) BOOL is35InchScreen;
147-
148-
@property(class, nonatomic, readonly) CGSize screenSizeFor67Inch;
149-
@property(class, nonatomic, readonly) CGSize screenSizeFor65Inch;
150-
@property(class, nonatomic, readonly) CGSize screenSizeFor61InchAndiPhone12;
151-
@property(class, nonatomic, readonly) CGSize screenSizeFor61Inch;
152-
@property(class, nonatomic, readonly) CGSize screenSizeFor58Inch;
153-
@property(class, nonatomic, readonly) CGSize screenSizeFor55Inch;
154-
@property(class, nonatomic, readonly) CGSize screenSizeFor54Inch;
155-
@property(class, nonatomic, readonly) CGSize screenSizeFor47Inch;
156-
@property(class, nonatomic, readonly) CGSize screenSizeFor40Inch;
157-
@property(class, nonatomic, readonly) CGSize screenSizeFor35Inch;
158-
159-
// 导航栏高度,包括竖屏,横屏,放大模式
160-
// 机型\高度 尺寸 竖屏 横屏 放大模式
161-
// 5,5s,5c,SE 4.0 44 32 不支持
162-
// 6,6s,7,8,SE2 4.7 44 32 32
163-
// 6,6s,7,8plus 5.5 44 44 32
164-
// X,XS,11Pro 5.8 44 32 32
165-
// XR,11 6.1 44 44 32
166-
// XS MAX,11Pro Max 6.5 44 44 32
167-
// 12mini 5.4 44 32 32
168-
// 12,12Pro 6.1 44 32 32
169-
// 12Pro Max 6.7 44 44 32
149+
@property (class, nonatomic, readonly) BOOL is35InchScreen;
150+
151+
@property (class, nonatomic, readonly) CGSize screenSizeFor67Inch;
152+
@property (class, nonatomic, readonly) CGSize screenSizeFor65Inch;
153+
@property (class, nonatomic, readonly) CGSize screenSizeFor61InchAndiPhone12;
154+
@property (class, nonatomic, readonly) CGSize screenSizeFor61Inch;
155+
@property (class, nonatomic, readonly) CGSize screenSizeFor58Inch;
156+
@property (class, nonatomic, readonly) CGSize screenSizeFor55Inch;
157+
@property (class, nonatomic, readonly) CGSize screenSizeFor54Inch;
158+
@property (class, nonatomic, readonly) CGSize screenSizeFor47Inch;
159+
@property (class, nonatomic, readonly) CGSize screenSizeFor40Inch;
160+
@property (class, nonatomic, readonly) CGSize screenSizeFor35Inch;
161+
162+
// 导航栏高度,包括竖屏,横屏,放大模式,非全屏模式
163+
// 机型\高度 尺寸 竖屏 横屏 放大模式 非全屏模式
164+
// 5,5s,5c,SE 4.0 44 32 不支持 56
165+
// 6,6s,7,8,SE2 4.7 44 32 32 56
166+
// 6,6s,7,8plus 5.5 44 44 32 56
167+
// X,XS,11Pro 5.8 44 32 32 56
168+
// XR,11 6.1 44 44 32 56
169+
// XS MAX,11Pro Max 6.5 44 44 32 56
170+
// 12mini 5.4 44 32 32 56
171+
// 12,12Pro 6.1 44 32 32 56
172+
// 12Pro Max 6.7 44 44 32 56
170173
// iPad iOS12之前是44,之后是50
171-
@property(class, nonatomic, readonly) CGFloat navBarHeight;
172-
@property(class, nonatomic, readonly) UIEdgeInsets safeAreaInsets;
173-
@property(class, nonatomic, readonly) CGRect statusBarFrame;
174-
@property(class, nonatomic, readonly) UIWindow *keyWindow;
174+
@property (class, nonatomic, readonly) CGFloat navBarHeight;
175+
@property (class, nonatomic, readonly) CGFloat navBarHeight_nonFullScreen;
176+
@property (class, nonatomic, readonly) CGFloat tabBarHeight;
177+
@property (class, nonatomic, readonly) UIEdgeInsets safeAreaInsets;
178+
@property (class, nonatomic, readonly) CGRect statusBarFrame;
179+
@property (class, nonatomic, readonly) UIWindow *keyWindow;
180+
181+
// 用于获取 isNotchedScreen 设备的 insets,注意对于 iPad Pro 11-inch 这种无刘海凹槽但却有使用 Home Indicator 的设备,它的 top 返回0,bottom 返回 safeAreaInsets.bottom 的值
182+
+ (UIEdgeInsets)safeAreaInsetsForDeviceWithNotch;
175183

176184
@end

0 commit comments

Comments
 (0)