Latest 1.1.2
Homepage https://github.com/Pircate/EachNavigationBar
License MIT
Platforms ios 8.0
Frameworks UIKit
Authors

CI Status
Version
Carthage compatible
License
iOS 8.0+
EachNavigationBar

中文文档

Example

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

Requirements

  • iOS 8.0+
  • Swift 4

Installation

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

Podfile

pod 'EachNavigationBar'

Cartfile

github "Pircate/EachNavigationBar"

Overview

EachNavigationBar
EachNavigationBar

Usage

Import

Swift

import EachNavigationBar

Objective-C

@import EachNavigationBar;

Enable

Swift

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

Objective-C

UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
nav.global_configuration.isEnabled = YES;

Setting

Global

Swift

nav.navigation.configuration.titleTextAttributes = [.foregroundColor: UIColor.blue]
nav.navigation.configuration.barTintColor = UIColor.red
nav.navigation.configuration.shadowImage = UIImage(named: "shadow")
nav.navigation.configuration.backImage = UIImage(named: "back")
nav.navigation.configuration.setBackgroundImage(UIImage(named: "nav"), for: .any, barMetrics: .default)

Objective-C

nav.global_configuration.titleTextAttributes = @{NSForegroundColorAttributeName: UIColor.blueColor};
nav.global_configuration.barTintColor = UIColor.redColor;
nav.global_configuration.shadowImage = [UIImage imageNamed:@"shadow"];
nav.global_configuration.backImage = [UIImage imageNamed:@"back"];
[nav.global_configuration setBackgroundImage:[UIImage imageNamed:@"nav"] for:UIBarPositionAny barMetrics:UIBarMetricsDefault];

Each view controller

Normal

Swift

navigation.bar  -> EachNavigationBar -> UINavigationBar
navigation.item -> UINavigationItem

// hide navigation bar
navigation.bar.isHidden = true

// set bar alpha
navigation.bar.alpha = 0.5

// set title alpha
navigation.bar.setTitleAlpha(0.5)

// set barButtonItem alpha
navigation.bar.setTintAlpha(0.5)
// if barButtonItem is customView
navigation.item.leftBarButtonItem?.customView?.alpha = 0.5
// if barButtonItem customized tintColor
navigation.item.leftBarButtonItem?.tintColor = navigation.item.leftBarButtonItem?.tintColor?.withAlphaComponent(0.5)

// remove blur effect
navigation.bar.isTranslucent = false

// hide bottom black line
navigation.bar.isShadowHidden = true

// set status bar style
navigation.bar.statusBarStyle = .lightContent

// if you want change navigation bar position
navigation.bar.isUnrestoredWhenViewWillLayoutSubviews = true

// navigation bar extra height
navigation.bar.extraHeight = 14

// custom back action
navigation.item.leftBarButtonItem?.action = #selector(backBarButtonAction)

Objective-C

self.each_navigationBar.xxx
self.each_navigationItem.xxx
LargeTitle(iOS 11.0+)

Swift

// show
if #available(iOS 11.0, *) {
    navigation.bar.prefersLargeTitles = true
}
// hide
if #available(iOS 11.0, *) {
    navigation.bar.prefersLargeTitles = false
}
// alpha
if #available(iOS 11.0, *) {
    navigation.bar.setLargeTitleAlpha(0.5)
}

Objective-C

// show
if (@available(iOS 11.0, *)) {
    self.each_navigationBar.prefersLargeTitles = YES;
}
// hide
if (@available(iOS 11.0, *)) {
    self.each_navigationBar.prefersLargeTitles = NO;
}
// alpha
if (@available(iOS 11.0, *)) {
    [self.each_navigationBar setLargeTitleAlpha:0.5];
}

Adjusts UIScrollView contentInset

Swift

adjustsScrollViewContentInset(scrollView)

Objective-C

[self adjustsScrollViewContentInset:self.scrollView];

For UITableViewController

Must remove observer when deinit

Swift

deinit {
    removeObserverForContentOffset()
}

Objective-C

- (void)dealloc {
    [self removeObserverForContentOffset];
}

Author

Pircate, [email protected]

License

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

Latest podspec

{
    "name": "EachNavigationBar",
    "version": "1.1.2",
    "summary": "A custom navigation bar of UIViewController.",
    "homepage": "https://github.com/Pircate/EachNavigationBar",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    },
    "authors": {
        "gaoX": "[email protected]"
    },
    "source": {
        "git": "https://github.com/Pircate/EachNavigationBar.git",
        "tag": "1.1.2"
    },
    "platforms": {
        "ios": "8.0"
    },
    "source_files": "EachNavigationBar/Classes/**/*",
    "frameworks": "UIKit",
    "swift_version": "4.2"
}

Pin It on Pinterest

Share This