Skip to content

Commit

Permalink
优化升级,release 3.0.2
Browse files Browse the repository at this point in the history
  • Loading branch information
QuintGao committed May 20, 2021
1 parent 1447c68 commit b49a958
Show file tree
Hide file tree
Showing 114 changed files with 326 additions and 191 deletions.
4 changes: 2 additions & 2 deletions GKNavigationBarViewController.podspec
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
Pod::Spec.new do |s|
s.name = "GKNavigationBarViewController"
s.version = "3.0.1"
s.version = "3.0.2"
s.summary = "自定义导航栏--导航栏联动"
s.homepage = "https://github.com/QuintGao/GKNavigationBarViewController"
s.license = "MIT"
s.authors = { "高坤" => "1094887059@qq.com" }
s.authors = { "QuintGao" => "1094887059@qq.com" }
s.social_media_url = "https://github.com/QuintGao"
s.platform = :ios, "9.0"
s.ios.deployment_target = "9.0"
Expand Down
2 changes: 1 addition & 1 deletion GKNavigationBarViewController/GKCategory/GKCategory.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// GKNavigationBarViewController
//
// Created by QuintGao on 2017/8/31.
// Copyright © 2017年 高坤. All rights reserved.
// Copyright © 2017年 QuintGao. All rights reserved.
//

#ifndef GKCategory_h
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// GKNavigationBarViewController
//
// Created by QuintGao on 2017/7/7.
// Copyright © 2017年 高坤. All rights reserved.
// Copyright © 2017年 QuintGao. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// GKNavigationBarViewController
//
// Created by QuintGao on 2017/7/7.
// Copyright © 2017年 高坤. All rights reserved.
// Copyright © 2017年 QuintGao. All rights reserved.
//

#import "UIBarButtonItem+GKCategory.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
// UIImage+GKCategory.h
// GKNavigationBar
//
// Created by gaokun on 2019/11/1.
// Created by QuintGao on 2019/11/1.
// Copyright © 2019 QuintGao. All rights reserved.
//

Expand Down
9 changes: 4 additions & 5 deletions GKNavigationBarViewController/GKCategory/UIImage+GKCategory.m
Original file line number Diff line number Diff line change
Expand Up @@ -2,19 +2,18 @@
// UIImage+GKCategory.m
// GKNavigationBar
//
// Created by gaokun on 2019/11/1.
// Created by QuintGao on 2019/11/1.
// Copyright © 2019 QuintGao. All rights reserved.
//

#import "UIImage+GKCategory.h"
#import "GKNavigationBarConfigure.h"

@implementation UIImage (GKCategory)

+ (UIImage *)gk_imageNamed:(NSString *)name {
NSString *bundleName = [@"GKNavigationBarViewController.bundle" stringByAppendingPathComponent:name];
NSString *frameWorkName = [@"Frameworks/GKNavigationBarViewController.framework/GKNavigationBarViewController.bundle" stringByAppendingPathComponent:name];

UIImage *image = [UIImage imageNamed:bundleName] ?: [UIImage imageNamed:frameWorkName];
if (![GKConfigure gk_libraryBundle]) return [UIImage imageNamed:name];
UIImage *image = [UIImage imageNamed:name inBundle:[GKConfigure gk_libraryBundle] compatibleWithTraitCollection:nil];
if (!image) image = [UIImage imageNamed:name];
return image;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// GKNavigationBarViewController
//
// Created by QuintGao on 2017/7/7.
// Copyright © 2017年 高坤. All rights reserved.
// Copyright © 2017年 QuintGao. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// GKNavigationBarViewController
//
// Created by QuintGao on 2017/7/7.
// Copyright © 2017年 高坤. All rights reserved.
// Copyright © 2017年 QuintGao. All rights reserved.
//

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

__block BOOL exist = NO;
[GKConfigure.shiledGuestureVCs enumerateObjectsUsingBlock:^(id _Nonnull obj, NSUInteger idx, BOOL * _Nonnull stop) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// GKNavigationBarViewController
//
// Created by QuintGao on 2017/10/13.
// Copyright © 2017年 高坤. All rights reserved.
// Copyright © 2017年 QuintGao. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// GKNavigationBarViewController
//
// Created by QuintGao on 2017/10/13.
// Copyright © 2017年 高坤. All rights reserved.
// Copyright © 2017年 QuintGao. All rights reserved.
//

#import "UINavigationItem+GKCategory.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// GKNavigationBarViewController
//
// Created by QuintGao on 2017/7/11.
// Copyright © 2017年 高坤. All rights reserved.
// Copyright © 2017年 QuintGao. All rights reserved.
//

#import <UIKit/UIKit.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// GKNavigationBarViewController
//
// Created by QuintGao on 2017/7/11.
// Copyright © 2017年 高坤. All rights reserved.
// Copyright © 2017年 QuintGao. All rights reserved.
//

#import "UIScrollView+GKCategory.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// GKNavigationBarViewController
//
// Created by QuintGao on 2017/7/7.
// Copyright © 2017年 高坤. All rights reserved.
// Copyright © 2017年 QuintGao. All rights reserved.
// 使用运行时为UIViewController添加分类

#import <UIKit/UIKit.h>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// GKNavigationBarViewController
//
// Created by QuintGao on 2017/7/7.
// Copyright © 2017年 高坤. All rights reserved.
// Copyright © 2017年 QuintGao. All rights reserved.
//

#import "UIViewController+GKCategory.h"
Expand Down Expand Up @@ -210,10 +210,18 @@ + (void)load {
}

- (void)gk_viewDidLoad {
// 初始化导航栏间距
self.gk_navItemLeftSpace = GKNavigationBarItemSpace;
self.gk_navItemRightSpace = GKNavigationBarItemSpace;
self.gk_disableFixNavItemSpace = [self checkFixNavItemSpace];
if ([self navItemSpaceChangeIfNeeded]) {
// 设置默认导航栏间距
self.gk_navItemLeftSpace = GKNavigationBarItemSpace;
self.gk_navItemRightSpace = GKNavigationBarItemSpace;
self.gk_disableFixNavItemSpace = [self checkFixNavItemSpace];
}
// 如果是根控制器,取消返回按钮
if (self.navigationController && self.navigationController.childViewControllers.count <= 1) {
if ([self isKindOfClass:[GKNavigationBarViewController class]]) {
((GKNavigationBarViewController *)self).gk_navLeftBarButtonItem = nil;
}
}
[self gk_viewDidLoad];
}

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

// bug fix:#41
if (!self.gk_disableFixNavItemSpace) {
if ([self navItemSpaceChangeIfNeeded] && !self.gk_disableFixNavItemSpace) {
// 每次控制器出现的时候重置导航栏间距
if (self.gk_navItemLeftSpace == GKNavigationBarItemSpace) {
self.gk_navItemLeftSpace = GKConfigure.navItemLeftSpace;
}else {
[GKConfigure updateConfigure:^(GKNavigationBarConfigure *configure) {
configure.gk_navItemLeftSpace = self.gk_navItemLeftSpace;
}];
}

if (self.gk_navItemRightSpace == GKNavigationBarItemSpace) {
self.gk_navItemRightSpace = GKConfigure.navItemRightSpace;
}else {
[GKConfigure updateConfigure:^(GKNavigationBarConfigure *configure) {
configure.gk_navItemRightSpace = self.gk_navItemRightSpace;
}];
}
}

Expand Down Expand Up @@ -399,6 +415,13 @@ - (BOOL)checkFixNavItemSpace {
return exist;
}

- (BOOL)navItemSpaceChangeIfNeeded {
if ([self isKindOfClass:[GKNavigationBarViewController class]]) {
return YES;
}
return [self.parentViewController isKindOfClass:[UINavigationController class]];
}

- (void)setNavBarAlpha:(CGFloat)alpha {
UINavigationBar *navBar = nil;
if ([self isKindOfClass:[GKNavigationBarViewController class]]) {
Expand Down
6 changes: 4 additions & 2 deletions GKNavigationBarViewController/GKConfigure/GKCommon.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// GKNavigationBarViewController
//
// Created by QuintGao on 2017/10/13.
// Copyright © 2017年 高坤. All rights reserved.
// Copyright © 2017年 QuintGao. All rights reserved.
// 一些公共的方法、宏定义、枚举等

#ifndef GKCommon_h
Expand Down Expand Up @@ -37,10 +37,12 @@
#define GK_STATUSBAR_HEIGHT [GKNavigationBarConfigure statusBarFrame].size.height
// 导航栏高度
#define GK_NAVBAR_HEIGHT [GKNavigationBarConfigure navBarHeight]
// 非全屏导航栏高度
#define GK_NAVBAR_HEIGHT_NFS [GKNavigationBarConfigure navBarHeight_nonFullScreen]
// 状态栏+导航栏高度
#define GK_STATUSBAR_NAVBAR_HEIGHT (GK_STATUSBAR_HEIGHT + GK_NAVBAR_HEIGHT)
// tabbar高度
#define GK_TABBAR_HEIGHT (GK_SAFEAREA_BTM + 49.0f)
#define GK_TABBAR_HEIGHT [GKNavigationBarConfigure tabBarHeight]

// 导航栏间距,用于不同控制器之间的间距
static const CGFloat GKNavigationBarItemSpace = -1;
Expand Down
6 changes: 4 additions & 2 deletions GKNavigationBarViewController/GKConfigure/GKNavigationBar.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// GKNavigationBarViewController
//
// Created by QuintGao on 2017/9/20.
// Copyright © 2017年 高坤. All rights reserved.
// Copyright © 2017年 QuintGao. All rights reserved.
// 自定义的导航条

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

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

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

@end
4 changes: 2 additions & 2 deletions GKNavigationBarViewController/GKConfigure/GKNavigationBar.m
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// GKNavigationBarViewController
//
// Created by QuintGao on 2017/9/20.
// Copyright © 2017年 高坤. All rights reserved.
// Copyright © 2017年 QuintGao. All rights reserved.
//

#import "GKNavigationBar.h"
Expand Down Expand Up @@ -32,7 +32,7 @@ - (void)layoutSubviews {
obj.frame = frame;
}else {
CGRect frame = obj.frame;
frame.origin.y = self.frame.size.height - GK_NAVBAR_HEIGHT;
frame.origin.y = self.frame.size.height - (self.gk_nonFullScreen ? GK_NAVBAR_HEIGHT_NFS : GK_NAVBAR_HEIGHT);
obj.frame = frame;
}
}];
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
// GKNavigationBarViewController
//
// Created by QuintGao on 2017/7/10.
// Copyright © 2017年 高坤. All rights reserved.
// Copyright © 2017年 QuintGao. All rights reserved.
//

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

/// 获取bundle
- (NSBundle *)gk_libraryBundle;

/// 判断当前速度是是否在敏感度范围
/// @param velocity 速度
- (BOOL)isVelocityInSensitivity:(CGFloat)velocity;
Expand All @@ -116,61 +119,66 @@
@property (class, nonatomic, readonly) BOOL isRegularScreen;

/// iPhone 12 Pro Max
@property(class, nonatomic, readonly) BOOL is67InchScreen;
@property (class, nonatomic, readonly) BOOL is67InchScreen;

/// iPhone XS Max / 11 Pro Max
@property(class, nonatomic, readonly) BOOL is65InchScreen;
@property (class, nonatomic, readonly) BOOL is65InchScreen;

/// iPhone 12 / 12 Pro
@property(class, nonatomic, readonly) BOOL is61InchScreenAndiPhone12;
@property (class, nonatomic, readonly) BOOL is61InchScreenAndiPhone12;

/// iPhone XR / 11
@property(class, nonatomic, readonly) BOOL is61InchScreen;
@property (class, nonatomic, readonly) BOOL is61InchScreen;

/// iPhone X / XS / 11Pro
@property(class, nonatomic, readonly) BOOL is58InchScreen;
@property (class, nonatomic, readonly) BOOL is58InchScreen;

/// iPhone 6,6s,7,8 Plus
@property(class, nonatomic, readonly) BOOL is55InchScreen;
@property (class, nonatomic, readonly) BOOL is55InchScreen;

/// iPhone 12 mini
@property(class, nonatomic, readonly) BOOL is54InchScreen;
@property (class, nonatomic, readonly) BOOL is54InchScreen;

/// iPhone 6,6s,7,8,SE2
@property(class, nonatomic, readonly) BOOL is47InchScreen;
@property (class, nonatomic, readonly) BOOL is47InchScreen;

/// iPhone 5,5s,5c,SE
@property(class, nonatomic, readonly) BOOL is40InchScreen;
@property (class, nonatomic, readonly) BOOL is40InchScreen;

/// iPhone 4
@property(class, nonatomic, readonly) BOOL is35InchScreen;

@property(class, nonatomic, readonly) CGSize screenSizeFor67Inch;
@property(class, nonatomic, readonly) CGSize screenSizeFor65Inch;
@property(class, nonatomic, readonly) CGSize screenSizeFor61InchAndiPhone12;
@property(class, nonatomic, readonly) CGSize screenSizeFor61Inch;
@property(class, nonatomic, readonly) CGSize screenSizeFor58Inch;
@property(class, nonatomic, readonly) CGSize screenSizeFor55Inch;
@property(class, nonatomic, readonly) CGSize screenSizeFor54Inch;
@property(class, nonatomic, readonly) CGSize screenSizeFor47Inch;
@property(class, nonatomic, readonly) CGSize screenSizeFor40Inch;
@property(class, nonatomic, readonly) CGSize screenSizeFor35Inch;

// 导航栏高度,包括竖屏,横屏,放大模式
// 机型\高度 尺寸 竖屏 横屏 放大模式
// 5,5s,5c,SE 4.0 44 32 不支持
// 6,6s,7,8,SE2 4.7 44 32 32
// 6,6s,7,8plus 5.5 44 44 32
// X,XS,11Pro 5.8 44 32 32
// XR,11 6.1 44 44 32
// XS MAX,11Pro Max 6.5 44 44 32
// 12mini 5.4 44 32 32
// 12,12Pro 6.1 44 32 32
// 12Pro Max 6.7 44 44 32
@property (class, nonatomic, readonly) BOOL is35InchScreen;

@property (class, nonatomic, readonly) CGSize screenSizeFor67Inch;
@property (class, nonatomic, readonly) CGSize screenSizeFor65Inch;
@property (class, nonatomic, readonly) CGSize screenSizeFor61InchAndiPhone12;
@property (class, nonatomic, readonly) CGSize screenSizeFor61Inch;
@property (class, nonatomic, readonly) CGSize screenSizeFor58Inch;
@property (class, nonatomic, readonly) CGSize screenSizeFor55Inch;
@property (class, nonatomic, readonly) CGSize screenSizeFor54Inch;
@property (class, nonatomic, readonly) CGSize screenSizeFor47Inch;
@property (class, nonatomic, readonly) CGSize screenSizeFor40Inch;
@property (class, nonatomic, readonly) CGSize screenSizeFor35Inch;

// 导航栏高度,包括竖屏,横屏,放大模式,非全屏模式
// 机型\高度 尺寸 竖屏 横屏 放大模式 非全屏模式
// 5,5s,5c,SE 4.0 44 32 不支持 56
// 6,6s,7,8,SE2 4.7 44 32 32 56
// 6,6s,7,8plus 5.5 44 44 32 56
// X,XS,11Pro 5.8 44 32 32 56
// XR,11 6.1 44 44 32 56
// XS MAX,11Pro Max 6.5 44 44 32 56
// 12mini 5.4 44 32 32 56
// 12,12Pro 6.1 44 32 32 56
// 12Pro Max 6.7 44 44 32 56
// iPad iOS12之前是44,之后是50
@property(class, nonatomic, readonly) CGFloat navBarHeight;
@property(class, nonatomic, readonly) UIEdgeInsets safeAreaInsets;
@property(class, nonatomic, readonly) CGRect statusBarFrame;
@property(class, nonatomic, readonly) UIWindow *keyWindow;
@property (class, nonatomic, readonly) CGFloat navBarHeight;
@property (class, nonatomic, readonly) CGFloat navBarHeight_nonFullScreen;
@property (class, nonatomic, readonly) CGFloat tabBarHeight;
@property (class, nonatomic, readonly) UIEdgeInsets safeAreaInsets;
@property (class, nonatomic, readonly) CGRect statusBarFrame;
@property (class, nonatomic, readonly) UIWindow *keyWindow;

// 用于获取 isNotchedScreen 设备的 insets,注意对于 iPad Pro 11-inch 这种无刘海凹槽但却有使用 Home Indicator 的设备,它的 top 返回0,bottom 返回 safeAreaInsets.bottom 的值
+ (UIEdgeInsets)safeAreaInsetsForDeviceWithNotch;

@end
Loading

0 comments on commit b49a958

Please sign in to comment.