Commit 733c8a28 authored by David黄金龙's avatar David黄金龙

1、导航栏

2、返回手势
parent 56c03b72
...@@ -9,6 +9,7 @@ import UIKit ...@@ -9,6 +9,7 @@ import UIKit
import ESTabBarController_swift import ESTabBarController_swift
import IQKeyboardManagerSwift import IQKeyboardManagerSwift
import SmartCodable import SmartCodable
import GKNavigationBarSwift
// 阿里云一键登录密钥 // 阿里云一键登录密钥
let AliCloudLoginSecret = "MuKKbWPm4DRHmZpgASqjI3L1HtiOlxyKWmocGnJhbiibdfaKlwYUj8ISgOexPHLAUAhdo6NNIGOi8oCAeqA1PO9b4ea3YwHXKnIa2u7BCTkd5L4IswsGgljfBeGIyRhoFCnCibix7RwQEqhrkdZ2KMsE/NtPrXfi+EU3oAnO9tXIztzvpAe75Pna2mUKMvO1qt4SSmPe4VnEOX5LCdbn7sGAvOLN8/l/fcCdEU7FA+AGLTY+547jlwan3wyJYJn0Sc8qnEW9LBxRwTDpEZPqyg==" let AliCloudLoginSecret = "MuKKbWPm4DRHmZpgASqjI3L1HtiOlxyKWmocGnJhbiibdfaKlwYUj8ISgOexPHLAUAhdo6NNIGOi8oCAeqA1PO9b4ea3YwHXKnIa2u7BCTkd5L4IswsGgljfBeGIyRhoFCnCibix7RwQEqhrkdZ2KMsE/NtPrXfi+EU3oAnO9tXIztzvpAe75Pna2mUKMvO1qt4SSmPe4VnEOX5LCdbn7sGAvOLN8/l/fcCdEU7FA+AGLTY+547jlwan3wyJYJn0Sc8qnEW9LBxRwTDpEZPqyg=="
...@@ -18,17 +19,26 @@ class AppDelegate: UIResponder, UIApplicationDelegate { ...@@ -18,17 +19,26 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
var window: UIWindow? var window: UIWindow?
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool { func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
//全局导航栏、返回事件/手势
setupNavBar()
//1.设置主窗口 //1.设置主窗口
setupRootVC() setupRootVC()
//2.通用UI设置 //2.通用UI设置
setupWholeUI() // setupWholeUI()
//3.其他第三方sdk设置 //3.其他第三方sdk设置
thirdSetting() thirdSetting()
return true return true
} }
func setupNavBar() {
GKConfigure.setupDefault()
}
} }
...@@ -70,7 +80,7 @@ extension AppDelegate { ...@@ -70,7 +80,7 @@ extension AppDelegate {
DispatchQueue.global().async { DispatchQueue.global().async {
//异步延迟设置 //异步延迟设置
DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.25) { [self] in DispatchQueue.main.asyncAfter(wallDeadline: .now() + 0.25) { [] in
//1、系统控件属性设置 //1、系统控件属性设置
//1.1 //1.1
UITextField.appearance().tintColor = .mainColor UITextField.appearance().tintColor = .mainColor
...@@ -97,12 +107,6 @@ extension AppDelegate { ...@@ -97,12 +107,6 @@ extension AppDelegate {
IQKeyboardManager.shared.enable = true IQKeyboardManager.shared.enable = true
IQKeyboardManager.shared.enableAutoToolbar = false IQKeyboardManager.shared.enableAutoToolbar = false
IQKeyboardManager.shared.shouldResignOnTouchOutside = true // 控制点击背景是否收起键盘 IQKeyboardManager.shared.shouldResignOnTouchOutside = true // 控制点击背景是否收起键盘
//webView 预加载
// BsWebViewPreloadManager.share.addPreloadingView()
//
customAppearance()
} }
} }
...@@ -112,16 +116,14 @@ extension AppDelegate { ...@@ -112,16 +116,14 @@ extension AppDelegate {
//1.设置主窗口 //1.设置主窗口
private func setupRootVC() { private func setupRootVC() {
let tabBarController = YHTabBarViewController() let tabBarController = YHTabBarViewController()
let v0 = YHNavigationController(rootViewController: YHHomeViewController()) let v0 = YHNavigationController(rootVC:YHHomeViewController())
let v1 = YHNavigationController(rootViewController: YHIntelligentServiceViewController()) let v1 = YHNavigationController(rootVC:YHIntelligentServiceViewController())
let v2 = YHNavigationController(rootViewController:YHMyViewController()) let v2 = YHNavigationController(rootVC:YHMyViewController())
v0.tabBarItem = ESTabBarItem.init(YHBasicContentView(),title: "首页", image: UIImage(named: "photo"), selectedImage: UIImage(named: "photo_1")) v0.tabBarItem = ESTabBarItem.init(YHBasicContentView(),title: "首页", image: UIImage(named: "photo"), selectedImage: UIImage(named: "photo_1"))
v1.tabBarItem = ESTabBarItem.init(YHBasicContentView(),title: "智慧服务", image: UIImage(named: "home"), selectedImage: UIImage(named: "home_1")) v1.tabBarItem = ESTabBarItem.init(YHBasicContentView(),title: "智慧服务", image: UIImage(named: "home"), selectedImage: UIImage(named: "home_1"))
v2.tabBarItem = ESTabBarItem.init(YHBasicContentView(),title: "我的", image: UIImage(named: "find"), selectedImage: UIImage(named: "find_1")) v2.tabBarItem = ESTabBarItem.init(YHBasicContentView(),title: "我的", image: UIImage(named: "find"), selectedImage: UIImage(named: "find_1"))
tabBarController.viewControllers = [v0,v1,v2]
tabBarController.viewControllers = [v0,v1, v2]
tabBarController.tabBar.backgroundColor = .white tabBarController.tabBar.backgroundColor = .white
......
...@@ -7,67 +7,27 @@ ...@@ -7,67 +7,27 @@
// //
import UIKit import UIKit
//import Kingfisher import GKNavigationBarSwift
class YHBaseViewController: UIViewController { class YHBaseViewController: UIViewController {
lazy var noDataView:YHNoDataTipView = {
let temp = YHNoDataTipView()
temp.frame = view.bounds
temp.isHidden = true
let tap = UITapGestureRecognizer(target: self, action: #selector(tapNodataViewEvent(tap:)))
temp.addGestureRecognizer(tap)
return temp
}()
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
// self.bs_setupLeftButton()
//0
setupNavigationAttributed()
//1、
view.addSubview(noDataView)
view.backgroundColor = .white view.backgroundColor = .white
} }
override var prefersStatusBarHidden: Bool {
return self.gk_statusBarHidden
}
override var preferredStatusBarStyle: UIStatusBarStyle {
return self.gk_statusBarStyle
}
deinit { deinit {
#if DEBUG #if DEBUG
// print(type(of: self))
// print("执行了方法:",terminator: "\t")
printLog(#function) printLog(#function)
#endif #endif
} }
} }
// MARK: - 私有操作方法
extension YHBaseViewController {
@objc func tapNodataViewEvent(tap: UITapGestureRecognizer) -> Void {
print("do nothing~~~ 子类根据具体情况来实现\(#function)")
}
func openFullScreenBackGes(_ openFlag : Bool) {
if self.navigationController is YHNavigationController {
self.navigationItem.hidesBackButton = !openFlag
}
}
///设置导航条属性
func setupNavigationAttributed(_ color: UIColor? = nil) {
if let color = color {
self.navigationController?.navigationBar.setBackgroundImage(UIImage.from(color: color), for: .default) //设置导航栏背景色
self.navigationController?.navigationBar.barTintColor = color
} else {
self.navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default) //设置导航栏背景透明色
self.navigationController?.navigationBar.barTintColor = nil
}
self.navigationController?.navigationBar.shadowImage = UIImage() //隐藏下划线
}
}
...@@ -7,16 +7,9 @@ ...@@ -7,16 +7,9 @@
// //
import UIKit import UIKit
public protocol BsNavigationControllerDelegate : NSObject {
func canBack() -> Bool
}
class YHNavigationController: UINavigationController { class YHNavigationController: UINavigationController {
weak var myDelegate : BsNavigationControllerDelegate?
override func viewDidLoad() { override func viewDidLoad() {
super.viewDidLoad() super.viewDidLoad()
self.interactivePopGestureRecognizer?.delegate = self
} }
override func pushViewController(_ viewController: UIViewController, animated: Bool) { override func pushViewController(_ viewController: UIViewController, animated: Bool) {
...@@ -27,28 +20,3 @@ class YHNavigationController: UINavigationController { ...@@ -27,28 +20,3 @@ class YHNavigationController: UINavigationController {
super.pushViewController(viewController, animated: animated) super.pushViewController(viewController, animated: animated)
} }
} }
// MARK: - UIGestureRecognizerDelegate, UINavigationBarDelegate
extension YHNavigationController : UIGestureRecognizerDelegate,UINavigationBarDelegate {
//这个方法是在手势将要激活前调用:返回YES允许右滑手势的激活,返回NO不允许右滑手势的激活
func gestureRecognizerShouldBegin(_ gestureRecognizer: UIGestureRecognizer) -> Bool {
print(#function)
if let returnValue = myDelegate?.canBack(){
return returnValue
} else {
#if DEBUG
print(#function)
print("myDelegate == nil 或者其他")
#endif
}
return true
}
public func navigationBar(_ navigationBar: UINavigationBar, shouldPop item: UINavigationItem) -> Bool {
if let returnValue = myDelegate?.canBack(){
return returnValue
}
return true
}
}
...@@ -8,6 +8,7 @@ ...@@ -8,6 +8,7 @@
import Foundation import Foundation
import RxSwift import RxSwift
import GKNavigationBarSwift
class YHHomeViewController: YHBaseViewController { class YHHomeViewController: YHBaseViewController {
//C 对应的 VM //C 对应的 VM
...@@ -32,8 +33,8 @@ class YHHomeViewController: YHBaseViewController { ...@@ -32,8 +33,8 @@ class YHHomeViewController: YHBaseViewController {
initView() initView()
//2.网络请求 //2.网络请求
bind() // bind()
requestData() // requestData()
} }
...@@ -42,7 +43,7 @@ class YHHomeViewController: YHBaseViewController { ...@@ -42,7 +43,7 @@ class YHHomeViewController: YHBaseViewController {
super.viewWillAppear(animated) super.viewWillAppear(animated)
//for test hjl //for test hjl
requestData() // requestData()
} }
...@@ -59,7 +60,10 @@ class YHHomeViewController: YHBaseViewController { ...@@ -59,7 +60,10 @@ class YHHomeViewController: YHBaseViewController {
} }
private func initView()->Void { private func initView()->Void {
navigationItem.title = "" // gk_navTitle = ""
// gk_navBarAlpha = 0.1
// gk_navLineHidden = true
view.backgroundColor = UIColor(hex:0xE9E9E9) view.backgroundColor = UIColor(hex:0xE9E9E9)
......
...@@ -30,6 +30,8 @@ class YHLoginViewController: YHBaseViewController { ...@@ -30,6 +30,8 @@ class YHLoginViewController: YHBaseViewController {
super.viewDidLoad() super.viewDidLoad()
setView() setView()
// Do any additional setup after loading the view. // Do any additional setup after loading the view.
gk_navBackgroundColor = .clear
gk_navShadowColor = .clear
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment