Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
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.
- Host: GitHub
- URL: https://github.com/pircate/aynavigationbar
- Owner: Pircate
- License: apache-2.0
- Created: 2017-12-01T03:21:55.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2018-08-25T03:44:49.000Z (over 6 years ago)
- Last Synced: 2024-03-14T18:17:50.963Z (10 months ago)
- Topics: navigationbar, objective-c, runtime, swizzling
- Language: Objective-C
- Homepage:
- Size: 11 MB
- Stars: 5
- Watchers: 3
- Forks: 2
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
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;
}
```