{"id":15036252,"url":"https://github.com/rickytan/rtrootnavigationcontroller","last_synced_at":"2025-05-14T19:05:17.793Z","repository":{"id":42203724,"uuid":"60745965","full_name":"rickytan/RTRootNavigationController","owner":"rickytan","description":"Implicitly make every view controller has its own navigation bar","archived":false,"fork":false,"pushed_at":"2024-08-13T16:24:24.000Z","size":5979,"stargazers_count":2158,"open_issues_count":77,"forks_count":378,"subscribers_count":51,"default_branch":"master","last_synced_at":"2025-04-10T04:38:42.607Z","etag":null,"topics":["custom-navigation","navigation","navigation-controller"],"latest_commit_sha":null,"homepage":"","language":"Objective-C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rickytan.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-06-09T03:04:55.000Z","updated_at":"2025-03-25T07:33:58.000Z","dependencies_parsed_at":"2024-06-18T11:08:25.424Z","dependency_job_id":"966a7d97-9419-4059-9df2-6dec01d7dd79","html_url":"https://github.com/rickytan/RTRootNavigationController","commit_stats":{"total_commits":122,"total_committers":10,"mean_commits":12.2,"dds":0.3770491803278688,"last_synced_commit":"6acef9a65f5a100bb7c6b50597c8273ee54257e7"},"previous_names":[],"tags_count":41,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickytan%2FRTRootNavigationController","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickytan%2FRTRootNavigationController/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickytan%2FRTRootNavigationController/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rickytan%2FRTRootNavigationController/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rickytan","download_url":"https://codeload.github.com/rickytan/RTRootNavigationController/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248161263,"owners_count":21057552,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["custom-navigation","navigation","navigation-controller"],"created_at":"2024-09-24T20:30:37.784Z","updated_at":"2025-04-10T04:51:39.271Z","avatar_url":"https://github.com/rickytan.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# RTRootNavigationController\n\n[![CI Status](http://img.shields.io/travis/rickytan/RTRootNavigationController.svg?style=flat)](https://travis-ci.org/rickytan/RTRootNavigationController)\n[![Version](https://img.shields.io/cocoapods/v/RTRootNavigationController.svg?style=flat)](http://cocoapods.org/pods/RTRootNavigationController)\n[![License](https://img.shields.io/cocoapods/l/RTRootNavigationController.svg?style=flat)](http://cocoapods.org/pods/RTRootNavigationController)\n[![Platform](https://img.shields.io/cocoapods/p/RTRootNavigationController.svg?style=flat)](http://cocoapods.org/pods/RTRootNavigationController)\n\n## iOS 15\nApple has changed some behavior of **UINavigationBar**([see](https://developer.apple.com/forums/thread/683265)）on iOS 15, developers can override this on demands:\n\niOS 15 上苹果改变了导航条的部分默认行为，开发者可以自己重写：\n\n```objective-c\n- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\n{\n    // setup appearance\n    if (@available(iOS 15.0, *)) {\n        [[UINavigationBar appearance] setScrollEdgeAppearance:({\n            UINavigationBarAppearance *app = [UINavigationBarAppearance new];\n            [app configureWithDefaultBackground];\n            // init app property\n            // app.backgroundColor = xxx;\n            // app.shadowColor = xxx;\n            app;\n        })];\n    } else {\n        // Fallback on earlier versions\n    }\n\n    return YES;\n}\n```\n\n## iPhone X\nHow many lines of code should I write to fit in iPhone X? Zero.\n\n我需要写多少代码来适配 **iPhone X**？0。\n\n![iphone-x](https://user-images.githubusercontent.com/1250207/30429339-abb20914-9989-11e7-9058-c967839315f4.gif)\n\n## Introduction\nMore and more apps use custom navigation bar for each different view controller, instead of one common, global navigation bar.\n\nThis 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.\n\n越来越多的应用为每一个 **VC** 设置单独的导航条，而不是之前那样使用一个全局统一的导航条，因为不同的 **VC** 有不同的视觉样式，前一个是蓝色的，后一个也许要做成红色、透明，或者干脆没有导航条。\n\n虽然开发者可以在每个 **VC** 的 `- (void)viewWillAppear` （想想为什么不是 `- (void)viewDidLoad`） 方法中设置自己所需的样式，但是在同一个导航条上来回修改，稍不注意就会导致样式混乱。另一种实现方式，是隐藏全局那个导航条，每个 **VC** 自己通过 `addSubview:(UIView *)view` 的方式自己设置导航条。这种实现是可行的，但是使用不方便了，如：\n- 无法使用 `self.navigationItem.rightBarButtonItem` 等来设置导航按钮，而必须自己手动往 `navigationBar` 上加；\n- 无法使用 `self.title` 来修改导航标题，而必须自己添加监听；\n- 无法方便地设置 `navigationBarHidden`；\n- 无法方便地自动调整 `contentInsets`。\n\n等等。\n\n本项目提供一种透明的方式，让开发者像以前一样使用导航器，同时，每个 `push` 进来的 **VC** 有自己独立的导航条。\n\n## Features\n\n* Custom navigation bar class support\n* Unwind support\n* Rotation support\n* Interactive pop enable and disable support\n* `Interface Builder` support\n\n* 每个 **VC** 支持自定义的 `navigationBarClass`\n* 支持 `unwind`（不知道什么是 `unwind`？请参考：[这里](https://developer.apple.com/library/ios/technotes/tn2298/_index.html)）\n* 支持转屏\n* 支持禁用交互式返回\n* 支持 `Interface Builder`\n\n![screenshot](./ScreenShot/1.png)\n\n![scrreecap](./ScreenShot/2.gif)\n\n## Usage\n\nAs an advise, please set `RTRootNavigationController` as your rootViewController:\n\n```objective-c\n- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions\n{\n\n    UIViewController *yourController = ...;\n    self.window.rootViewController = [[RTRootNavigationController alloc] initWithRootViewController:yourController];\n    return YES;\n}\n```\n\nyou can implement following method to customize back bar button item (**Recommended**):\n\n```objective-c\n- (UIBarButtonItem *)rt_customBackItemWithTarget:(id)target\n                                          action:(SEL)action\n{\n    return [[UIBarButtonItem alloc] initWithTitle:NSLocalizedString(@\"Back\", nil)\n                                            style:UIBarButtonItemStylePlain\n                                           target:target\n                                           action:action];\n}\n```\n\nor just set `useSystemBackBarButtonItem` to **YES** and use the default one.\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n## __Notice__(Only for below v0.6)\n\nYour **ViewController** hierarchy will change to:\n```\nRTRootNavigationController\n    `- RTContainerViewController\n    |       `- RTContainerNavigationController\n    |               `- YourViewController1\n    `- RTContainerViewController\n            `- RTContainerNavigationController\n                    `- YourViewController2\n```\nSo, 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](https://github.com/rickytan/RTRootNavigationController/blob/master/RTRootNavigationController/Classes/UIViewController%2BRTRootNavigationController.h#L36)** and **[Here](https://github.com/rickytan/RTRootNavigationController/blob/master/RTRootNavigationController/Classes/RTRootNavigationController.h#L81)**.\n\n## Requirements\n\n* **iOS 7** and up\n* **Xcode 7** and up\n\n## Installation\n\nRTRootNavigationController is available through [CocoaPods](http://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod \"RTRootNavigationController\"\n```\n\n## Author\n\nrickytan, ricky.tan.xin@gmail.com\n\n## Alternatives\n\n- [**JTNavigationController**](https://github.com/JNTian/JTNavigationController)\n  - 支持全屏返回\n- [**FDFullscreenPopGesture**](https://github.com/forkingdog/FDFullscreenPopGesture)\n  - 使用原生的 *UINavigationController*，在 `- (void)viewWillAppear` 中做处理\n  - 支持全屏返回\n  \n## Apps Integrated\n\n* [网易美学](https://itunes.apple.com/cn/app/%E7%BD%91%E6%98%93%E7%BE%8E%E5%AD%A6-%E9%A2%9C%E5%80%BC%E6%9C%80%E9%AB%98%E7%9A%84%E7%BE%8E%E5%A6%86%E7%A4%BE%E5%8C%BA/id1147533466?mt=8)\n\n## License\n\nRTRootNavigationController is available under the MIT license. See the LICENSE file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickytan%2Frtrootnavigationcontroller","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frickytan%2Frtrootnavigationcontroller","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frickytan%2Frtrootnavigationcontroller/lists"}