项目作者: kingjiajie

项目描述 :
在V1.11.0 版本上修改EachNavigationBar (支持Objc的版本),使版本支持iOS13,解决1.11.0版本在iOS13下Crash的问题
高级语言: Swift
项目地址: git://github.com/kingjiajie/EachNavigationBar_Objc.git
创建时间: 2019-10-28T06:20:15Z
项目社区:https://github.com/kingjiajie/EachNavigationBar_Objc

开源协议:MIT License

下载


EachNavigationBar

License
Platform

注意,该版本为原作者EachNavigationBar (https://github.com/Pircate/EachNavigationBar) V1.11.0 版本进行修改。
注意,该版本为原作者EachNavigationBar (https://github.com/Pircate/EachNavigationBar) V1.11.0 版本进行修改。
注意,该版本为原作者EachNavigationBar (https://github.com/Pircate/EachNavigationBar) V1.11.0 版本进行修改。

———-(该版本只在1.11.0上修改了对iOS13的支持,原作者后续的特性更新在该副本是没有的,如需使用新特性,请移步上面GitHub原作者地址,使用最新版本。谢谢。)(如有侵权,及时联系,我马上删除,谢谢)

由于原作者在1.11.0之后发布的版本移除了对OC的支持,后续版本不支持OC进行编译,只支持swift。
由于此前我接入该项目时候使用的是OC,所以只能在版本上停留在1.11.0,由于iOS13的更新,1.11.0使用会Crash,所以修改了原1.11.0代码,使项目支持iOS13。

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

  • iOS 9.0
  • Swift 4.2

Installation

EachNavigationBar is available through CocoaPods. To install
it, simply add the following line to your Podfile or Cartfile:

Podfile

  1. //pod 最新版本 原作者版本(https://github.com/Pircate/EachNavigationBar
  2. pod 'EachNavigationBar'
  3. //使用修改版
  4. pod 'EachNavigationBar_Objc'

Overview


Usage

Import

Swift

  1. import EachNavigationBar

Objective-C

  1. @import EachNavigationBar;

Enable

Swift

  1. let nav = UINavigationController(rootViewController: vc)
  2. nav.navigation.configuration.isEnabled = true

Objective-C

  1. UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
  2. nav.navigation_configuration.isEnabled = YES;

Setting

Global

Swift

  1. nav.navigation.configuration.titleTextAttributes = [.foregroundColor: UIColor.blue]
  2. nav.navigation.configuration.barTintColor = UIColor.red
  3. nav.navigation.configuration.shadowImage = UIImage(named: "shadow")
  4. nav.navigation.configuration.backBarButtonItem = .init(style: .image(UIImage(named: "back")), tintColor: UIColor.red)
  5. nav.navigation.configuration.setBackgroundImage(UIImage(named: "nav"), for: .any, barMetrics: .default)

Objective-C

  1. nav.navigation_configuration.titleTextAttributes = @{NSForegroundColorAttributeName: UIColor.blueColor};
  2. nav.navigation_configuration.barTintColor = UIColor.redColor;
  3. nav.navigation_configuration.shadowImage = [UIImage imageNamed:@"shadow"];
  4. nav.navigation_configuration.backBarButtonItem = [[BackBarButtonItem alloc] initWithImage:[UIImage imageNamed:@"back"]];
  5. [nav.navigation_configuration setBackgroundImage:[UIImage imageNamed:@"nav"] for:UIBarPositionAny barMetrics:UIBarMetricsDefault];

Each view controller

Normal

Swift

  1. navigation.bar -> EachNavigationBar -> UINavigationBar
  2. navigation.item -> UINavigationItem
  3. // hide navigation bar
  4. navigation.bar.isHidden = true
  5. // set bar alpha
  6. navigation.bar.alpha = 0.5
  7. // set title alpha
  8. navigation.bar.setTitleAlpha(0.5)
  9. // set barButtonItem alpha
  10. navigation.bar.setTintAlpha(0.5)
  11. // if barButtonItem is customView
  12. navigation.item.leftBarButtonItem?.customView?.alpha = 0.5
  13. // if barButtonItem customized tintColor
  14. navigation.item.leftBarButtonItem?.tintColor = navigation.item.leftBarButtonItem?.tintColor?.withAlphaComponent(0.5)
  15. // remove blur effect
  16. navigation.bar.isTranslucent = false
  17. // hides shadow image
  18. navigation.bar.isShadowHidden = true
  19. // set status bar style
  20. navigation.bar.statusBarStyle = .lightContent
  21. // set back bar button item
  22. navigation.bar.backBarButtonItem = .init(style: .title("Back"), tintColor: .red)
  23. // allow back
  24. navigation.bar.backBarButtonItem.shouldBack = { item in
  25. // do something
  26. return false
  27. }
  28. // handler before back
  29. navigation.bar.backBarButtonItem.willBack = {
  30. // do something
  31. }
  32. // handler after back
  33. navigation.bar.backBarButtonItem.didBack = {
  34. // do something
  35. }
  36. // if you want change navigation bar position
  37. navigation.bar.automaticallyAdjustsPosition = false
  38. // navigation bar additional height
  39. navigation.bar.additionalHeight = 14
  40. // navigation bar additional view
  41. navigation.bar.additionalView = UIView()
  42. // item padding
  43. navigation.bar.layoutPaddings = UIEdgeInsets(top: 0, left: 8, bottom: 0, right: 8)
  44. // shadow
  45. navigation.bar.shadow = Shadow(
  46. color: UIColor.black.cgColor,
  47. opacity: 0.5,
  48. offset: CGSize(width: 0, height: 3))

Objective-C

  1. self.navigation_bar.xxx
  2. self.navigation_item.xxx
LargeTitle(iOS 11.0+)

UINavigationController

  1. // enable
  2. nav.navigation.prefersLargeTitles()

UIViewController

  1. // show or hide
  2. navigation.bar.prefersLargeTitles = true
  3. // alpha
  4. navigation.bar.setLargeTitleAlpha(0.5)

Author

原作者信息:
Pircate, gao497868860@163.com

License

EachNavigationBar is available under the MIT license. See the LICENSE file for more info.