{"id":19269306,"url":"https://github.com/listenzz/hbdstatusbar","last_synced_at":"2026-02-27T07:05:32.516Z","repository":{"id":56913073,"uuid":"162116838","full_name":"listenzz/HBDStatusBar","owner":"listenzz","description":"A library handling status bar hidden","archived":false,"fork":false,"pushed_at":"2021-03-13T14:05:40.000Z","size":68,"stargazers_count":22,"open_issues_count":3,"forks_count":3,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-15T17:55:00.611Z","etag":null,"topics":["uinavigationbar","uinavigationcontroller","uistatusbar"],"latest_commit_sha":null,"homepage":null,"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/listenzz.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-12-17T10:57:03.000Z","updated_at":"2023-10-12T12:27:20.000Z","dependencies_parsed_at":"2022-08-20T20:20:33.208Z","dependency_job_id":null,"html_url":"https://github.com/listenzz/HBDStatusBar","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/listenzz%2FHBDStatusBar","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/listenzz%2FHBDStatusBar/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/listenzz%2FHBDStatusBar/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/listenzz%2FHBDStatusBar/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/listenzz","download_url":"https://codeload.github.com/listenzz/HBDStatusBar/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250128338,"owners_count":21379493,"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":["uinavigationbar","uinavigationcontroller","uistatusbar"],"created_at":"2024-11-09T20:19:23.882Z","updated_at":"2026-02-27T07:05:32.469Z","avatar_url":"https://github.com/listenzz.png","language":"Objective-C","funding_links":[],"categories":[],"sub_categories":[],"readme":"# HBDStatusBar\n\n官方提供了一套 API 来控制状态栏的显示和隐藏\n\n```objc\n\n- (UIStatusBarAnimation)preferredStatusBarUpdateAnimation;\n\n- (UIViewController *)childViewControllerForStatusBarHidden;\n\n- (BOOL)prefersStatusBarHidden;\n\n- (void)setNeedsStatusBarAppearanceUpdate;\n\n```\n\n这一套规则在没有使用 UINavigationBar 之前，是正常的，生活是美好的。但是一旦涉及到 UINavigationBar, 就令人抓狂了，经历过的都懂，无须多言。\n\n本库因此而生，解决有 UINavigationBar 时，隐藏状态栏带来的各种问题。\n\n## Usage\n\n使用  `hbd_statusBarHidden`  取代  `prefersStatusBarHidden`\n使用  `hbd_setNeedsStatusBarHiddenUpdate`  取代  `setNeedsStatusBarAppearanceUpdate`\n\n在需要隐藏状态栏的控制器中编写如下代码\n\n```objc\n#import \u003cHBDStatusBar/UIViewController+StatusBar.h\u003e\n\n- (void)viewDidLoad\n{\n    [super viewDidLoad];\n    self.hbd_statusBarHidden = YES;\n}\n```\n\n或者\n\n```objc\n- (BOOL)hbd_statusBarHidden {\n    return YES;\n}\n```\n\n这是声明式 API，其它不需要隐藏状态栏的页面什么也不需要做。\n\n如果需要动态隐藏或显示状态栏，在设置  `hbd_statusBarHidden`  后调用 `hbd_setNeedsStatusBarHiddenUpdate` 即可。\n\n本库可以和 UINavigationBar 友好相处\n\n你仍然可以通过 `preferredStatusBarUpdateAnimation` 来指定状态栏显示或隐藏时的动画，仍然可以通过 `childViewControllerForStatusBarHidden` 来指定由哪个子控制器来决定是否隐藏状态栏\n\n如果你遇到 UINavigationBar 的相关问题，请访问 [HBDNavigationBar](https://github.com/listenzz/HBDNavigationBar)。\n\n## 更新至 iOS 13\n\n为了适配 iOS 13, 在需要隐藏状态栏的 UIViewController 中实现如下方法\n\n```objc\n- (BOOL)prefersStatusBarHidden {\n    if (@available(iOS 13.0, *)) {\n        // 返回值和 self.hbd_barHidden 设定的值一致\n        // 千万别返回 self.hbd_barHidden，因为 prefersStatusBarHidden 比 viewDidLoad 先执行\n        return YES;\n    } else {\n        // 固定返回 NO, 由 self.hbd_barHidden 决定是否隐藏状态栏\n        return NO;\n    }\n}\n```\n\n为什么不用 method swizzle 搞定 prefersStatusBarHidden？\n\n因为我搞不定，如果你搞定了，请务必告诉我。感谢。\n\n\n## Installation\n\nHBDStatusBar is available through [CocoaPods](https://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'HBDStatusBar'\n```\n\n## Author\n\nlistenzz@163.com\n\n## License\n\nHBDStatusBar 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%2Flistenzz%2Fhbdstatusbar","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Flistenzz%2Fhbdstatusbar","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Flistenzz%2Fhbdstatusbar/lists"}