Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/pircate/aynavigationbar

A custom navigation bar for each view controller written in Objective-C.
https://github.com/pircate/aynavigationbar

navigationbar objective-c runtime swizzling

Last synced: 26 days ago
JSON representation

A custom navigation bar for each view controller written in Objective-C.

Awesome Lists containing this project

README

        

# AYNavigationBar

[![Build Status](https://travis-ci.org/Pircate/AYNavigationBar.svg?branch=master)](https://travis-ci.org/Pircate/AYNavigationBar)
[![Version](https://img.shields.io/cocoapods/v/AYNavigationBar.svg?style=flat)](http://cocoapods.org/pods/AYNavigationBar)
[![License](https://img.shields.io/cocoapods/l/AYNavigationBar.svg?style=flat)](http://cocoapods.org/pods/AYNavigationBar)
[![Platform](https://img.shields.io/cocoapods/p/AYNavigationBar.svg?style=flat)](http://cocoapods.org/pods/AYNavigationBar)

## Overview

![snapshot](https://github.com/CodeABug/AYNavigationBar/blob/master/demo.gif)

## Installation

Use CocoaPods

``` ruby
pod 'AYNavigationBar'
```

## Usage

### Import

``` objc
#import
```

### To enable AYNavigationBar of a navigation controller

``` objc
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
nav.ay_navigation.configuration.enabled = YES;
```

### Setting
#### Global

``` objc
UINavigationController *nav = [[UINavigationController alloc] initWithRootViewController:vc];
nav.ay_navigation.configuration.titleTextAttributes = @{NSForegroundColorAttributeName: [UIColor blueColor]};
nav.ay_navigation.configuration.barTintColor = [UIColor cyanColor];
nav.ay_navigation.configuration.backgroundImage = [UIImage imageNamed:@"nav"];
nav.ay_navigation.configuration.shadowImage = [UIImage imageNamed:@"shadow"];
nav.ay_navigation.configuration.translucent = NO;
nav.ay_navigation.configuration.barStyle = UIBarStyleBlack;
nav.ay_navigation.configuration.extraHeight = 14;
```

#### Each view controller
##### normal

``` objc
self.ay_navigation.bar -> UINavigationBar
self.ay_navigation.item -> UINavigationItem

// remove blur effect
self.ay_navigation.bar.translucent = NO;

// hide bottom black line
self.ay_navigation.bar.shadowImage = [[UIImage alloc] init];
// if version < iOS 11.0, also need:
[self.ay_navigation.bar setBackgroundImage:[[UIImage alloc] init] forBarMetrics:UIBarMetricsDefault];

// if you need to set status bar style lightContent
self.navigationController.navigationBar.barStyle = UIBarStyleBlack;

// if you want change navigation bar position
self.ay_navigation.bar.isUnrestoredWhenViewWillLayoutSubviews = YES;
```

##### largeTitle(iOS 11.0+)

``` objc
// enable
if (@available(iOS 11.0, *)) {
self.navigationController.navigationBar.prefersLargeTitles = YES; // once
}
// show
if (@available(iOS 11.0, *)) {
self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeAlways;
}
// hide
if (@available(iOS 11.0, *)) {
self.navigationItem.largeTitleDisplayMode = UINavigationItemLargeTitleDisplayModeNever;
}
```