• Stars
    star
    248
  • Rank 163,560 (Top 4 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created almost 7 years ago
  • Updated almost 2 years ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Replicating the 'clear' navigation bar style of the iOS 12 Apple TV app.

TONavigationBar

Version GitHub license Platform

TONavigationBar is an open-source subclass of UINavigationBar that adds the ability to set the background content of the navigation bar to transparent, and then gradually bring it back in as the user scrolls through the page.

Apple uses this effect in their 'modern' style iOS apps (Music, TV, App Store) for any content deemed 'notable'. Unfortunately, while it seems like a trivial thing to be able to do, none of the APIs necessary to reconfigure a UINavigationBar to be transparent in that way exist. TONavigationBar internally re-implements a variety of the UINavigationBar functionality in order to make this possible.

Features

  • Fully integrates into UINavigationController.
  • Participates in UINavigationController's 'swipe-to-go-back' gesture.
  • Supports light and dark themed apps.
  • Features an animation to restore to the normal UINavigationBar appearance.
  • A target UIScrollView may be specified in order to avoid having to manually pass information to the bar.
  • Library also features TOHeaderImageView, a header view that may be used as the banner in scroll views.

System Requirements

iOS 11.0 or above

Installation

As a CocoaPods Dependency

Objective-C

Add the following to your Podfile:

pod 'TONavigationBar'

Manual Installation

All of the necessary source files are in the TONavigationBar, folder. Simply copy that folder to your Xcode project and import all of the files in it.

Examples

TONavigationBar has been designed to be as hands-off as possible. It integrates with UINavigationController and only needs to be interacted with when changing the visibility of the background content.

Basic Implementation

Integrating with UINavigationController

#import "TONavigationBar.h"

UINavigationController *navigationController = [[UINavigationController alloc] initWithNavigationBarClass:[TONavigationBar class] toolbarClass:nil];

Showing and Hiding the Background Content

#import "TONavigationBar.h"

@implementation MyViewController // A child of the `UINavigationController` stack

- (void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    [self.navigationController.to_navigationBar setBackgroundHidden:YES animated:animated forViewController:self];
    [self.navigationController.to_navigationBar setTargetScrollView:self.tableView minimumOffset:200.0f]; // 200.0f is the height of the header view
}

@end

Creating and Configuring a Header View

#import "TOHeaderImageView.h"

@interface MyTableViewController () <UIScrollViewDelegate>

@property (nonatomic, strong) TOHeaderImageView *headerView;

@end

@implementation MyTableViewController

- (void)viewDidLoad {
    [super viewDidLoad];
	
    self.headerView = [[TOHeaderImageView alloc] initWithImage:[UIImage imageNamed:@"MyPicture.jpg"] height:200.0f];
    self.headerView.shadowHidden = NO;
    self.tableView.tableHeaderView = self.headerView;
}

- (void)scrollViewDidScroll:(UIScrollView *)scrollView
{
    self.headerView.scrollOffset = scrollView.contentOffset.y;
}

@end

Architecture of TONavigationBar

In order to modify UINavigationBar to the same style Apple uses, a few things need to happen:

  • The background view, including the separator line need to be removed.
  • The title label in the center needs to be removed.
  • The tint color needs to be set to white (To make the buttons white).
  • The bar style needs to be set to UIBarStyleBlack (Which makes UINavigationController change the status bar style to white.)

Changing the tint color and bar style are trivial, however there are no public APIs provided by Apple to easily control the alpha of just the background views, or the title label.

The way TONavigationBar solves this is as follows:

  • The official background views are removed by using [UINavigationBar setBackgroundImage:[[UIImage alloc] init] and then a wholly custom set are put in their place. This also means transitioning it back while scrolling is possible.
  • The title label is controlled by manually traversing UINavigationBar's internal views, finding the right one, and then overriding its presentation by Apple's code.

Is this App Store safe?

Yes. It should be. The only slightly dubious thing this view does is that it traverses some internal Apple views to find the title label. However no private APIs are called in the process, so that should be no problem.

That being said, internal view traversal is always a terrible way to go, and this library MAY break in future versions of iOS without maintenance. Thankfully, it's set up so if it does break, the absolute worst thing that can happen is that the title label will always be visible.

Credits

TONavigationBar was originally created by Tim Oliver as a component for iComics, a comic reader app for iOS.

Firewatch Wallpaper by Campo Santo and is used for illustrative purposes. Firewatch is available on Steam.

iOS Device mockups used in the screenshot created by Pixeden.

License

TONavigationBar is licensed under the MIT License, please see the LICENSE file. analytics

More Repositories

1

TOCropViewController

A view controller for iOS that allows users to crop portions of UIImage objects
Objective-C
4,571
star
2

TOWebViewController

A view controller class for iOS that allows users to view web pages directly within an app.
Objective-C
1,490
star
3

TORoundedButton

A high-performance button control with rounded corners for iOS.
Objective-C
481
star
4

PassKit-Business-Card

A template for iOS Wallet passes that can be used like business cards.
Objective-C
387
star
5

TOPasscodeViewController

A modal passcode input and validation view controller for iOS
Objective-C
383
star
6

TOStatusBarSimulator

Replaces the iOS system status bar with a configurable mockup for the purpose of marketing screenshots.
Objective-C
199
star
7

TOSegmentedControl

A segmented control in the style of iOS 13 compatible with previous versions of iOS.
Objective-C
195
star
8

TOGlintyStringView

A non-App Store safe re-implementation of the 'slide to unlock' visual effect on iOS.
Objective-C
186
star
9

TOSMBClient

An Objective-C binding around the libDSM SMB client library.
Objective-C
177
star
10

TOActionSheet

A custom-designed reimplementation of the UIActionSheet control for iOS
Objective-C
173
star
11

TORoundedTableView

A subclass of UITableView that styles it like Settings.app on iPad
Objective-C
160
star
12

RealmBrowser-iOS

A native iOS debugging framework for introspecting Realm files on device
Objective-C
148
star
13

TOSearchBar

A basic reimplementation of UISearchBar with easier theming, and nicer animation.
Objective-C
104
star
14

TOScrollBar

An interactive scroll bar for traversing comically massive scroll views.
Objective-C
91
star
15

PHP-Framework-Classes

A collection of PHP classes I've developed for personal projects.
PHP
83
star
16

TOInsetGroupedTableView

An iOS 11 back-port of the grouped inset table view style in iOS 13.
Objective-C
79
star
17

TODocumentPickerViewController

An open-source implementation for picking files/folders out of an online API
Objective-C
78
star
18

WebPKit

A framework that extends a variety of Cocoa APIs with capabilities for encoding and decoding WebP files for all of Apple's platforms.
Swift
67
star
19

TOSplitViewController

A split view controller that can display up to three view controllers at once.
Objective-C
60
star
20

Beeline

An extremely lean implementation on the classic iOS router pattern.
Swift
59
star
21

TOFileSystemObserver

A bullet-proof mechanism for detecting any changes made to the contents of a folder in iOS and macOS.
Objective-C
38
star
22

TOAlertViewController

A modern looking modal popup UI component for iOS and iPadOS.
Objective-C
24
star
23

TOAppSettings

An object wrapper for storing properties in NSUserDefaults.
Objective-C
24
star
24

TOAppRater

A very small library to provide a classier way of requesting app reviews.
Objective-C
21
star
25

TOBrowserActivityKit

A set of UIActivity subclasses for opening NSURL objects in Chrome or Safari.
Objective-C
20
star
26

TOReachability

A lightweight, unit-tested class that detects network status changes on iOS.
Objective-C
20
star
27

WebP-Cocoa

An unofficial collection of precompiled WebP binaries for all of Apple's current platforms.
Shell
18
star
28

BuildingHighPerformanceListsAndCollectionViews

A mirror of Apple's sample code for high performance collection views in iOS 15.
Swift
18
star
29

TOBadgeView

A badge view that can be used to accessorize other UI elements in iOS.
Objective-C
16
star
30

TOPagingView

A paging scroll view that can handle arbitrary numbers of page views at run-time.
Objective-C
14
star
31

TOBorderView

A flexible container view featuring a solid background with rounded corners.
Objective-C
14
star
32

TOGridView

A lightweight collection view for iOS
Objective-C
13
star
33

TORevealViewController

An alternative to UISplitViewController on both iPhone and iPad
Objective-C
11
star
34

TORoundedWindow

A UIWindow overlay that adds rounded corners to an iOS app display region
Objective-C
10
star
35

TOSegmentedTabBarController

A splittable tab bar controller controlled by a segmented control view.
Objective-C
9
star
36

TOWebContentViewController

A view controller to quickly render arbitrary local HTML content.
Objective-C
9
star
37

TODocumentsDirectoryWatcher

Automatically observes an iOS app's Documents directory for file changes.
Objective-C
8
star
38

TOPagerView

A UIScrollView subclass that allows paged horizontal swiping with a re-use mechansim similar to UITableView.
Objective-C
8
star
39

TOSegmentedSplitViewController

A split view controller that is controlled by a segmented control on small devices
Objective-C
8
star
40

TOFileKit

Not ambitious at all.
Objective-C
7
star
41

AVRecorder

A mirror of the AVRecorder sample app for macOS by Apple
Objective-C
7
star
42

TOTabBarController

A tab bar controller that mimics the vertical tool bar style of Tweetbot 4.
Objective-C
7
star
43

PhotoSorter

A quick and dirty CLI tool for sorting my photo library
Swift
7
star
44

YozoraRedux

My personal color theme I use in Xcode. Tweaked from Yozora and Sublime Text.
7
star
45

LargeImageDownsizing

Mirror of Apple's sample code for partially decoding regions of images into memory
Objective-C
6
star
46

RLMFastImage

A prototype for storing raw pixel data in Realm.
Objective-C
6
star
47

WebServerKit

A fork of the #1 HTTP server for iOS, macOS & tvOS
Objective-C
5
star
48

TOFileAttributes

A Realm-like dynamic property wrapper that maps to APFS extended file attributes.
Objective-C
5
star
49

BTLE-Transfer

A mirror of the Apple sample code that demonstrates how to work with Core Bluetooth
Objective-C
5
star
50

Spackle

A collection of convenience properties and extensions for laying out views in UIKit
Swift
5
star
51

UIColor-LegacySemanticColors

A UIColor category that backports the new semantic colors of iOS 13 to iOS 12.
Objective-C
5
star
52

SLVolumeButtonListener

A class for iOS that lets apps intercept events from the device's volume buttons
Objective-C
4
star
53

TimOliver

My GitHub README.md repository. Feel free to copy and re-use this as a template for your own GitHub account! ๐Ÿ˜
4
star
54

TOLocalServiceDiscovery

A wrapper for detecting accessible devices locally via Bonjour.
Objective-C
4
star
55

AnimeLabPiP

A Safari Extension to enable Picture-in-Picture with AnimeLab's web player.
JavaScript
4
star
56

TOTARArchive

A basic library to allow streaming data out of TAR files
Objective-C
3
star
57

TOStackView

A barebones container view for UIKit that stacks collections of subviews
Objective-C
3
star
58

icomics.co

The source code to the official iComics website.
PHP
3
star
59

CI

A central repo for the build scripts used for testing and deploying my projects
Ruby
3
star
60

TOPropertyAccessor

Swift Property Wrappers, but in Objective-C. And done horribly.
Objective-C
3
star
61

simple-iphone-image-processing

Automatically exported from code.google.com/p/simple-iphone-image-processing
Objective-C++
2
star
62

CloudKit-PHP

For server-to-server comms from PHP to CloudKit.
PHP
2
star
63

UIDevice-UserInterfaceExtendedIdiom

An Objective-C category to allow easier detection of newer iOS device UI idioms (such as iPhone 5).
Objective-C
2
star
64

vCard

The source code to my online vCard site.
PHP
2
star
65

Dexter

An extensible encyclopedia engine
1
star
66

rchat

Swift
1
star
67

SteamAppCatalog

A dump of all of the JSON files extracted from Steam's store
1
star
68

SteamLibraryDatabase

A small utility to copy the entire Steam game library to a Realm database.
Objective-C
1
star
69

ObjC-WebPImage

An Objective-C framework for encoding and decoding WebP image files
Objective-C
1
star