All Projects → alexiscn → WXNavigationBar

alexiscn / WXNavigationBar

Licence: MIT license
Handle UINavigationBar like WeChat. Simple and easy to use.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to WXNavigationBar

Tlyshynavbar
Unlike all those arrogant UINavigationBar, this one is shy and humble! Easily create auto-scrolling navigation bars!
Stars: ✭ 3,780 (+3158.62%)
Mutual labels:  uinavigationcontroller, navigationbar
Zingle
Zingle – An alert will display underneath your UINavigationBar 🎅
Stars: ✭ 109 (-6.03%)
Mutual labels:  uinavigationcontroller, uinavigationbar
NXNavigationExtension
🔥 Lightweight, simple, and easy-to-use NavigationBar library.
Stars: ✭ 121 (+4.31%)
Mutual labels:  uinavigationcontroller, uinavigationbar
Mtransparentnav
Change NavigationBar's color and transparency 导航栏颜色渐变,通过给viewController添加属性,可方便控制title、item、导航栏颜色变化
Stars: ✭ 109 (-6.03%)
Mutual labels:  navigationbar
Ios.blog.swiftui search bar in navigation bar
🔍 SwiftUI search bar in the navigation bar.
Stars: ✭ 124 (+6.9%)
Mutual labels:  navigationbar
CircularRevealKit
Circular reveal animations made easy
Stars: ✭ 24 (-79.31%)
Mutual labels:  uinavigationcontroller
YRNavigationBarPure
Global navigation bar pure transition
Stars: ✭ 69 (-40.52%)
Mutual labels:  uinavigationbar
Bubble Navigation
🎉 [Android Library] A light-weight library to easily make beautiful Navigation Bar with ton of 🎨 customization option.
Stars: ✭ 1,537 (+1225%)
Mutual labels:  navigationbar
RRNavigationBar
bring UINavigationBar to UIViewController.
Stars: ✭ 11 (-90.52%)
Mutual labels:  navigationbar
Easydropdown
💧 Fantastic dropdown in Swift
Stars: ✭ 254 (+118.97%)
Mutual labels:  navigationbar
Teaset
A UI library for react native, provides 20+ pure JS(ES6) components, focusing on content display and action control.
Stars: ✭ 2,845 (+2352.59%)
Mutual labels:  navigationbar
Zxnavigationbar
灵活轻量的自定义导航栏,导航栏属于控制器view,支持导航栏联动,一行代码实现【导航栏背景图片设置、导航栏渐变、折叠、修改Item大小和边距、自定义导航栏高度、全屏手势返回、pop拦截、仿系统导航栏历史堆栈】等各种效果
Stars: ✭ 230 (+98.28%)
Mutual labels:  navigationbar
React Site Nav
A kick ass site menu powered by styled components inspired by Stripe.
Stars: ✭ 155 (+33.62%)
Mutual labels:  navigationbar
ALButtonMenu
A simple, fully customizable menu solution for iOS.
Stars: ✭ 45 (-61.21%)
Mutual labels:  uinavigationcontroller
Edge To Edge
Full screen Android apps using simple Kotlin DSL
Stars: ✭ 118 (+1.72%)
Mutual labels:  navigationbar
AHCategoryView
A navigation view for categories
Stars: ✭ 29 (-75%)
Mutual labels:  navigationbar
Systemuihelper
Helper for dealing with Android System UI visibility
Stars: ✭ 108 (-6.9%)
Mutual labels:  navigationbar
JNAPushPopCompletionBlock
Completion Block for UINavigationController Push/Pop UIViewController
Stars: ✭ 40 (-65.52%)
Mutual labels:  uinavigationcontroller
BottomNavigationBar
A light bottom navigation bar in Android supporting Tint mode.
Stars: ✭ 48 (-58.62%)
Mutual labels:  navigationbar
Tiptoes
Simple navigation bar in the bottom, a beautiful discretion in your UI.
Stars: ✭ 221 (+90.52%)
Mutual labels:  navigationbar

Platform CocoaPods Compatible Carthage Compatible License

WXNavigationBar

WeChat NavigationBar

Features

  • Support transparent navigationbar
  • Support navigationbar background image
  • Support navigationbar large title mode
  • Support iOS 13 dark mode
  • Support fullscreen pop gesture
  • As Simple as using UINavigationBar

Requirements

  • iOS 9.0+
  • Xcode 11.0+
  • Swift 5.0+

Installation

CocoaPods

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

use_frameworks!

pod 'WXNavigationBar', '~> 2.3.6'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. To integrate WXNavigationBar into your Xcode project using Carthage, specify it in your Cartfile:

github alexiscn/WXNavigationBar

Swift Package Manager

The Swift Package Manager is a tool for automating the distribution of Swift code and is integrated into the swift compiler. It is in early development, but WXNavigationBar does support its use on supported platforms.

Once you have your Swift package set up, adding WXNavigationBar as a dependency is as easy as adding it to the dependencies value of your Package.swift.

dependencies: [
    .package(url: "https://github.com/alexiscn/WXNavigationBar.git", .upToNextMajor(from: "2.3.6"))
]

Design Principle

WXNavigation make the actual UINavigationBar transparent and add a view as a fake navigation bar to the view controller.

The actual navigation bar still handles the touch events, the fake navigation bar do the display staffs, eg: backgroundColor, backgroundImage.

So you use navigation bar as usual. when you want to handle the display things, you use WXNavigationBar

Getting Started

In your AppDelegate.swift

import WXNavigationBar

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
    // ...    
    WXNavigationBar.setup()
}

You can customize WXNavigationBar if needed. There are two ways to configure WXNavigationBar: via WXNavigationBar.NavBar or via UIViewController properties.

UINavigationController based configuration

Using WXNavigationBar.NavBar to configure WXNavigationBar will effect all viewcontrollers.

In your AppDelegate.swift

import WXNavigationBar

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {

    // ...
    
    // Customize WXNavigationBar if needed (Optional)
    // WXNavigationBar.NavBar.backImage = UIImage(named: "xxx")
}

You can configure following options:

/// Back Image for Navigation Bar
public static var backImage: UIImage? = Utility.backImage

/// Use custom view to create back button.
/// Note: You do not need to add tap event to custom view. It's handled in WXNavigationBar.
public static var backButtonCustomView: UIView? = nil
        
/// Background Image for NavigationBar
public static var backgroundImage: UIImage? = nil

/// Background color for NavigationBar
public static var backgroundColor: UIColor = UIColor(white: 237.0/255, alpha: 1.0)

/// Tint Color for NavigationBar
public static var tintColor = UIColor(white: 24.0/255, alpha: 1.0)

/// Shadow Image for NavigationBar
public static var shadowImage: UIImage? = UIImage()

/// Enable fullscreen pop gesture
public static var fullscreenPopGestureEnabled = false

ViewController based configuration

You can also configure specific view controller by override properties that WXNavigationBar supported.

Background Color

You can configure background color of navigation bar.

/// Background color of fake NavigationBar
/// Default color is UIColor(white: 237.0/255, alpha: 1.0)
override var wx_navigationBarBackgroundColor: UIColor? {
    return .white
}

Background Image

You can confgiure navigation bar background using image.

override var wx_navigationBarBackgroundImage: UIImage? {
    return UIImage(named: "icons_navigation_bar")
}

System blur navigation bar

If you want to use system alike blured navigation bar:

override var wx_useSystemBlurNavBar: Bool {
    return true
}

NavigationBar bar tint color

By setting wx_barBarTintColor, you actually setting barTintColor of navigationController?.navigationBar

override var wx_barBarTintColor: UIColor? {
    return .red
}

NavigationBar tint color

By setting wx_baTintColor, you actually setting tintColor of navigationController?.navigationBar

override var wx_barTintColor: UIColor? {
    return .black
}

Shadow Image

You can specify navigation bar shadow image for specific view controller(eg: solid color line or gradient color line):

override var wx_shadowImage: UIImage? {
    return UIImage(named: "icons_navigation_bar_shadow_line")
}

Shadow Image Tint Color

You can create shadow image from color, this property will overwrite wx_shadowImage

override var wx_shadowImageTintColor: UIColor? {
    return .red
}

Back Button Image

You can specify navigation bar back image for specific view controller:

override var wx_backImage: UIImage? {
    return UIImage(named: "icons_view_controller_back_image")
}

Back Button Custom View

You can specify back button with custom view:

override var wx_backButtonCustomView: UIView? {
    let label = UILabel()
    label.text = "back"
    label.textAlignment = .center
    return label
}

Disable Interactive Pop Gesture

override var wx_disableInteractivePopGesture: Bool {
    return true
}

fullscreen interactive pop gesture

override var wx_fullScreenInteractivePopEnabled: Bool {
    return false
}

interactivePopMaxAllowedDistanceToLeftEdge

override wx_interactivePopMaxAllowedDistanceToLeftEdge: CGFloat {
    return view.bounds.width * 0.5
}

Advance usage

Here is some advance usage suggestions for WXNavigationBar.

Transparent Navigation Bar

There are several ways to make navigation bar transparent.

alpha
wx_navigationBar.alpha = 0
hidden
wx_navigationBar.isHidden = true
background color
override var wx_navigationBarBackgroundColor: UIColor? {
    return .clear
}

alpha and hidden make wx_navigationBar invisible, while backgroundColor just change the color of wx_navigationBar

Dynamic update navigation bar

You can dynamically update navigation bar, such as dynamically update while scrolling.

See MomentViewController for details.

wx_navigationBar

wx_navigationBar is a subclass of UIView, so you can do anything with wx_navigationBar that can be done with UIView.

Handle back button event

If you want to do something when user tap back button, you can override wx_backButtonClicked in your view controller. For example, you can present alert when user tap back button.

override func wx_backButtonClicked() {
    let alert = UIAlertController(title: "Are you sure to exit", message: nil, preferredStyle: .alert)
    alert.addAction(UIAlertAction(title: "OK", style: .default, handler: { [weak self] _ in
        self?.navigationController?.popViewController(animated: true)
    }))
    alert.addAction(UIAlertAction(title: "Cancel", style: .cancel, handler: { _ in
        
    }))
    present(alert, animated: true, completion: nil)
}

Notes

Child View Controller

wx_navigationBar can be overlaid when you dynamically add child view controller. So it's your responsibility to bring wx_navigationBar to front.

// addChild(controller) or addSubview

view.bringSubviewToFront(wx_navigationBar)

License

WXNavigationBar is MIT-licensed. LICENSE

中文文档

你可以参考中文文档

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].