• Stars
    star
    2,152
  • Rank 21,437 (Top 0.5 %)
  • Language
    Objective-C
  • License
    MIT License
  • Created over 8 years ago
  • Updated 3 months ago

Reviews

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

Repository Details

Implicitly make every view controller has its own navigation bar

RTRootNavigationController

CI Status Version License Platform

iOS 15

Apple has changed some behavior of UINavigationBar(see)on iOS 15, developers can override this on demands:

iOS 15 上苹果改变了导航条的部分默认行为,开发者可以自己重写:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
    // setup appearance
    if (@available(iOS 15.0, *)) {
        [[UINavigationBar appearance] setScrollEdgeAppearance:({
            UINavigationBarAppearance *app = [UINavigationBarAppearance new];
            [app configureWithDefaultBackground];
            // init app property
            // app.backgroundColor = xxx;
            // app.shadowColor = xxx;
            app;
        })];
    } else {
        // Fallback on earlier versions
    }

    return YES;
}

iPhone X

How many lines of code should I write to fit in iPhone X? Zero.

我需要写多少代码来适配 iPhone X?0。

iphone-x

Introduction

More and more apps use custom navigation bar for each different view controller, instead of one common, global navigation bar.

This project just help develops to solve this problem in a tricky way, develops use this navigation controller in a farmilar way just like you used to be, and you can have each view controller a individual navigation bar.

越来越多的应用为每一个 VC 设置单独的导航条,而不是之前那样使用一个全局统一的导航条,因为不同的 VC 有不同的视觉样式,前一个是蓝色的,后一个也许要做成红色、透明,或者干脆没有导航条。

虽然开发者可以在每个 VC- (void)viewWillAppear (想想为什么不是 - (void)viewDidLoad) 方法中设置自己所需的样式,但是在同一个导航条上来回修改,稍不注意就会导致样式混乱。另一种实现方式,是隐藏全局那个导航条,每个 VC 自己通过 addSubview:(UIView *)view 的方式自己设置导航条。这种实现是可行的,但是使用不方便了,如:

  • 无法使用 self.navigationItem.rightBarButtonItem 等来设置导航按钮,而必须自己手动往 navigationBar 上加;
  • 无法使用 self.title 来修改导航标题,而必须自己添加监听;
  • 无法方便地设置 navigationBarHidden
  • 无法方便地自动调整 contentInsets

等等。

本项目提供一种透明的方式,让开发者像以前一样使用导航器,同时,每个 push 进来的 VC 有自己独立的导航条。

Features

  • Custom navigation bar class support

  • Unwind support

  • Rotation support

  • Interactive pop enable and disable support

  • Interface Builder support

  • 每个 VC 支持自定义的 navigationBarClass

  • 支持 unwind(不知道什么是 unwind?请参考:这里

  • 支持转屏

  • 支持禁用交互式返回

  • 支持 Interface Builder

screenshot

scrreecap

Usage

As an advise, please set RTRootNavigationController as your rootViewController:

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{

    UIViewController *yourController = ...;
    self.window.rootViewController = [[RTRootNavigationController alloc] initWithRootViewController:yourController];
    return YES;
}

you can implement following method to customize back bar button item (Recommended):

- (UIBarButtonItem *)rt_customBackItemWithTarget:(id)target
                                          action:(SEL)action
{
    return [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@"Back", nil)
                                            style:UIBarButtonItemStylePlain
                                           target:target
                                           action:action];
}

or just set useSystemBackBarButtonItem to YES and use the default one.

To run the example project, clone the repo, and run pod install from the Example directory first.

Notice(Only for below v0.6)

Your ViewController hierarchy will change to:

RTRootNavigationController
    `- RTContainerViewController
    |       `- RTContainerNavigationController
    |               `- YourViewController1
    `- RTContainerViewController
            `- RTContainerNavigationController
                    `- YourViewController2

So, if you access self.navigationController it returns a container navigation controller, and its viewControllers will always be 1, i.e. self. Instead, your have to use self.rt_navigationController.rt_viewController to get all siblings, as metioned Here and Here.

Requirements

  • iOS 7 and up
  • Xcode 7 and up

Installation

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

pod "RTRootNavigationController"

Author

rickytan, [email protected]

Alternatives

Apps Integrated

License

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

More Repositories

1

RTImageAssets

A Xcode plugin to automatically generate 2x, 1x image from 3x image for you, or upscale to 3x from 2x
Objective-C
2,455
star
2

GPUUtilization

measure GPU hardware utilization on iOS Devices
Objective-C
126
star
3

RTViewAttachment

Attach a custom UIView to text view
Objective-C
47
star
4

RTComponentTableView

A Componentized UITableView implementation
Objective-C
44
star
5

RTIconButton

A Interface Builder configurable UIButton with a image icon
Objective-C
41
star
6

RTTextView

text with emotion editing
Objective-C
30
star
7

RTagCloudView

a UITableView like API tag cloud view
Objective-C
21
star
8

iZJU

iZJU--浙大移动校园客户端
Objective-C
21
star
9

WechatPlaneSwift

微信打飞机 Swift 实现
Swift
19
star
10

RTTinyPNGWebAPIPlugin

A Xcode plugin which calls http://tinypng.com api to minimize image assets
Objective-C
19
star
11

DepthEffectImage

Swift
18
star
12

XPaste

A Xcode Source Extension to power up your text paste abilities
Objective-C
18
star
13

AllCities

中国所有城市与地区json数据
Objective-C
17
star
14

RTBlockCallChecker

A helper utility to check if a block has been called
Objective-C
15
star
15

RTPagedCollectionViewLayout

A paged collection view layout
Objective-C
14
star
16

RTHeadedColumnView

Multi-column content with a common header view
Objective-C
12
star
17

RSlideView

This is a very easy-to-use slide view, which has a UITablview like API, and reusable cell for memory saving.
Objective-C
10
star
18

RTPagingViewController

A simple to use Paging View Controller, a Android ViewPager Implimetation
Objective-C
10
star
19

CLAnimation

a cocos2d-like animation API based on CAAnimation of UIView (not finished yet, can you help me?)
Objective-C
10
star
20

APNGImageSerialization

a warpper of APNG support for iOS
Objective-C
9
star
21

RTDraggableBadge

a drag to clear badge view
Objective-C
8
star
22

Z

浙江大学团委“校园App”参赛项目
Objective-C
8
star
23

FIXiT

Yet another javascript fixing solution for Objective-C
Objective-C
7
star
24

RTNavigationController

A Navigation Controller and A Side Controller
Objective-C
7
star
25

RTPlaceholderTextView

A UITextView with placeholder supported
Objective-C
5
star
26

RTInteractivePush

UINavigationController interactive push support
Objective-C
5
star
27

json-valid

A json data model validate kit for NodeJS
JavaScript
5
star
28

DemoXcodeExtension

A Demo for fast selection of compound statement or block.
Objective-C
5
star
29

libpng-apng

The patched libpng. The Animated Portable Network Graphics (APNG) is an unofficial extension of the Portable Network Graphics (PNG) format. APNG patch provides APNG support to libpng.
C
5
star
30

RTID

A solution for ios device Unique Identifier
Objective-C
4
star
31

QLPDFAsset

Objective-C
4
star
32

iSAM

A copy of [iSAM](https://svn.csail.mit.edu/isam/) compiles on windows
C
4
star
33

iOS7LongShadowDemo

A simple demo to indicate how iOS 7 long shadow can be created with CAReplicatorLayer
Objective-C
3
star
34

Cocoa-Style-OpenGL

Why there are so many fucking MACROs used in OpenGL? Totally no type, and hard to remember, also uneasy to use auto-complete in IDE. Why don't we just wrap them like Apple, say, typedef enum { kTypeType0, kTypeType1} Type, so that we can easily find out what to use ?
C
3
star
35

RTGridView

A light weight grid view
Objective-C
2
star
36

iZJU-v3

iZJU v3.1.3
Objective-C
2
star
37

RTTextField

A drop-in replacement for UITextField with input limitation
Objective-C
2
star
38

UICollectionViewCellAutomaticDimension

Automatic sizing support for UICollectionView
Objective-C
2
star
39

Snooker

A Turbo C snooker
C++
2
star
40

UIAutomationJS

A UIAutomation javascript stub, used for code completion in WebStorm or something else
JavaScript
2
star
41

ChemOrder

有机化学实验室仪器预约
JavaScript
1
star
42

KALOFution

KALOFution
C
1
star
43

LeetCode

My solutions for http://oj.leetcode.com
C++
1
star
44

snooker-java-applet

浙江大学Java的课程作业,代码很烂,基本可玩,仅供参考
Java
1
star
45

RAutoAdjust

Automaticlly adjust position when keyboard pop out, to make it visible
Objective-C
1
star
46

Magnet

1
star
47

cracker

Objective-C++
1
star
48

YahooWeather

As the title, a yahoo weather wrapper
Objective-C
1
star
49

Easay

An App for wareable device
Objective-C
1
star
50

RFolderView

to be finished
Objective-C
1
star
51

YellowPage

浙江大学校园黄页信息抓取及结构化进数据库实现过程
PHP
1
star