Giter Site home page Giter Site logo

eachnavigationbar's Introduction

EachNavigationBar

CI Status Version Carthage compatible License Platform 中文文档

中文文档

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 or Carthage. To install it, simply add the following line to your Podfile or Cartfile:

Podfile

pod 'EachNavigationBar'

Cartfile

github "Pircate/EachNavigationBar"

Overview

Usage

Import

import EachNavigationBar

Enable

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

Setting

Global

nav.navigation.configuration.titleTextAttributes = [.foregroundColor: UIColor.blue]

nav.navigation.configuration.barTintColor = UIColor.red

nav.navigation.configuration.shadowImage = UIImage(named: "shadow")

nav.navigation.configuration.setBackgroundImage(UIImage(named: "nav"), for: .any, barMetrics: .default)

Each view controller

Normal
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

// hides shadow image
navigation.bar.isShadowHidden = true

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

// set back bar button item
navigation.bar.backBarButtonItem = .init(style: .title("Back"), tintColor: .red)

// allow back
navigation.bar.backBarButtonItem.shouldBack = { item in
    // do something
    return false
}

// handler before back
navigation.bar.backBarButtonItem.willBack = {
    // do something
}

// handler after back
navigation.bar.backBarButtonItem.didBack = {
    // do something
}

// if you want change navigation bar position
navigation.bar.automaticallyAdjustsPosition = false

// navigation bar additional height
navigation.bar.additionalHeight = 14

// navigation bar additional view
navigation.bar.additionalView = UIView()

// item padding
navigation.bar.layoutPaddings = UIEdgeInsets(top: 0, left: 8, bottom: 0, right: 8)

// shadow
navigation.bar.shadow = Shadow(
    color: UIColor.black.cgColor,
    opacity: 0.5,
    offset: CGSize(width: 0, height: 3))
LargeTitle(iOS 11.0+)

UINavigationController

// enable
nav.navigation.prefersLargeTitles()

UIViewController

// show or hide
navigation.bar.prefersLargeTitles = true

// alpha
navigation.bar.setLargeTitleAlpha(0.5)

Author

Pircate, [email protected]

License

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

eachnavigationbar's People

Contributors

pircate avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.