{"id":2478,"url":"https://github.com/jogendra/BadgeHub","last_synced_at":"2025-08-06T14:33:01.106Z","repository":{"id":34085548,"uuid":"169398506","full_name":"jogendra/BadgeHub","owner":"jogendra","description":"A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.","archived":false,"fork":false,"pushed_at":"2022-06-17T15:19:45.000Z","size":79,"stargazers_count":810,"open_issues_count":13,"forks_count":70,"subscribers_count":11,"default_branch":"master","last_synced_at":"2024-12-01T15:05:13.179Z","etag":null,"topics":["animations","cocoapods","hacktoberfest","ios","notifications","pod","podfile","swift","swift-framework","swift-language","swift5","xcode"],"latest_commit_sha":null,"homepage":"https://jogendra.github.io/","language":"Swift","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/jogendra.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":"2019-02-06T11:53:12.000Z","updated_at":"2024-11-04T06:36:03.000Z","dependencies_parsed_at":"2022-08-08T00:00:53.906Z","dependency_job_id":null,"html_url":"https://github.com/jogendra/BadgeHub","commit_stats":null,"previous_names":["jogendra/bedgenotifichub"],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jogendra%2FBadgeHub","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jogendra%2FBadgeHub/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jogendra%2FBadgeHub/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/jogendra%2FBadgeHub/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/jogendra","download_url":"https://codeload.github.com/jogendra/BadgeHub/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":228915455,"owners_count":17991409,"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":["animations","cocoapods","hacktoberfest","ios","notifications","pod","podfile","swift","swift-framework","swift-language","swift5","xcode"],"created_at":"2024-01-05T20:16:14.749Z","updated_at":"2024-12-09T15:30:49.341Z","avatar_url":"https://github.com/jogendra.png","language":"Swift","funding_links":[],"categories":["UI","Libs","Swift","UI [🔝](#readme)"],"sub_categories":["Badge","UI"],"readme":"# BadgeHub\n\nA way to quickly add a notification badge icon to any view.\n\n\u003cimg src=\"https://user-images.githubusercontent.com/20956124/52379966-080a5f00-2a92-11e9-8c85-9c34fabd4641.png\"\u003e\n\n[![Version](https://img.shields.io/cocoapods/v/BadgeHub.svg?style=flat)](https://cocoapods.org/pods/BadgeHub)\n[![License](https://img.shields.io/cocoapods/l/BadgeHub.svg?style=flat)](https://cocoapods.org/pods/BadgeHub)\n[![Platform](https://img.shields.io/cocoapods/p/BadgeHub.svg?style=flat)](https://cocoapods.org/pods/BadgeHub)\n\n![Blink](https://imgur.com/AEgi5tW.gif) ![Bump](https://i.imgur.com/238tikf.gif) ![Pop](https://i.imgur.com/aQ0sOtZ.gif) ![Custom](https://i.imgur.com/PhlDWXW.gif) ![setCircle](https://i.imgur.com/8CtI0nf.gif) ![showCount](https://i.imgur.com/VHdp2vO.gif) ![mix](https://i.imgur.com/4DohGxr.gif) ![hideCount](https://i.imgur.com/E3hOrX5.gif)\n\n## Demo/Example\nFor demo:\n\n```ruby\n$ pod try BadgeHub\n```\n\nTo run the example project, clone the repo, and run `pod install` from the Example directory first.\n\n```ruby\n$ cd Example\n```\n\n```ruby\n$ pod install\n```\n\nIf you don't have CocoaPods installed, grab it with `[sudo] gem install cocoapods`.\n\n```ruby\n$ open BadgeHub.xcworkspace\n```\n\n## Requirements\n\n- iOS 10.0 or later\n- Swift 5+\n- Xcode 10+\n\n## Installation\n\n#### CocoaPods\n\nBadgeHub is available through [CocoaPods](https://cocoapods.org). To install\nit, simply add the following line to your Podfile:\n\n```ruby\npod 'BadgeHub'\n```\n\n#### Manual Installation\nJust drag the `BadgeHub.swift` files into your project.\n\n## Usage\n\nInitialization.\n\n```swift\nlet hub = BadgeHub(view: yourView) // Initially count set to 0\n```\n\nInitializer for setting badge to bar button items.\n\n```swift\nlet hub = BadgeHub(barButtonItem: UIBarButtonItem)\n```\n\nIncrease count value by **1**.\n\n```swift\nhub.increment()\n```\n\nIncrease count by some int value.\n\n```swift\nhub.increment(by: Int)\n```\n\nDecrease count value by **1**.\n\n```swift\nhub.decrement()\n```\n\nDecrease count by some int value.\n\n```swift\nhub.decrement(by: Int)\n```\n\nSet count to static integer value.\n\n```swift\nhub.setCount(newCount: Int)\n```\nGet value of current count on badge.\n\n```swift\nhub.getCurrentCount() // returns Int value of current count.\n```\n\nCombine actions\n\n![mix](https://i.imgur.com/4DohGxr.gif)\n\n```swift\nhub.increment()\nhub.pop()\nhub.blink()\n```\n**Don't forget to `import BadgeHub`**\n\n## Customization\n\nChange the color of the notification circle, also the text color of count label.\n\n![setCircleColor](https://i.imgur.com/MrsGB4p.gif)\n\n```swift\nhub.setCircleColor(_ circleColor: UIColor?, label labelColor: UIColor?)\n```\nChange the border color and border width of the circle\n\n![Custom](https://i.imgur.com/PhlDWXW.gif)\n\n```swift\nhub.setCircleBorderColor(_ color: UIColor?, borderWidth width: CGFloat)\n```\nSet the frame of the notification badge circle relative to the view.\n\n![setCircle](https://i.imgur.com/8CtI0nf.gif)\n\n```swift\nhub.setCircleAtFrame(_ frame: CGRect)\n```\nMove the circle (left/right or up/down).\n\n```swift\nhub.moveCircleBy(x: CGFloat, y: CGFloat)\n```\nChanges the size of the circle. setting a scale of 1 has no effect.\n\n```swift\nhub.scaleCircleSize(by scale: CGFloat)\n```\nHide the count (Blank Badge). Keep in mind that this method is for hiding just count, not the badge.\n\n![hideCount](https://i.imgur.com/E3hOrX5.gif)\n\n```swift\nhub.hideCount()\n```\nShow count again on the badge.\n\n![showCount](https://i.imgur.com/VHdp2vO.gif)\n\n```swift\nhub.showCount()\n```\n\nHide the badge from your view.\n\n```swift\nhub.hide()\n```\n\nShow again the badge. Badge will staye hidden even after calling this method, if current count on badge is \u003c= 0.\n\n```swift\nhub.show()\n```\nSet max count which can be displayed. This method can be used to restrict the maximum count can be set on the badge. Default value for max count is `100000`. If you increase current count to more than max count, badge will display it like `500+` (if max count is 500).\n\n```swift\nhub.setMaxCount(to: Int)\n```\n\nSet the font of the count label.\n\n```swift\nhub.setCountLabelFont(_ font: UIFont?)\n```\nGet the current font set on the count label.\n\n```swift\nhub.getCountLabelFont()\n```\n\nSet alpha to badge.\n\n```swift\nhub.setAlpha(alpha: CGFloat)\n```\n\n## Animations\n\nPop out and pop in the badge.\n\n![Pop](https://i.imgur.com/aQ0sOtZ.gif)\n\n```swift\nhub.pop()\n```\nMake badge blinking.\n\n![Blink](https://imgur.com/AEgi5tW.gif)\n\n```swift\nhub.blink()\n```\nAnimation that jumps similar to macOS dock icons.\n\n![Bump](https://i.imgur.com/238tikf.gif)\n\n```swift\nhub.bump()\n```\n\n## TROUBLESHOOTING\n\n**Notification isn't showing up!**\n* If the hub value is \u003c 1, the circle hides.  Try calling `increment()`.\n* Make sure the view you set the hub to is visible (i.e. did you call `self.view.addSubview(yourView)`?).\n* Make sure you didn't call `hideCount()` anywhere. Call `showCount()` to counter this.\n\n**Badge is not hiding even after setting value to 0**\n* Make sure you are setting zero count on correct BadgeHub instance.\n* Try calling `checkZero()` method after setting count to 0.\n* Varify if current count is \u003c= 0 by calling `getCurrentCount()` method.\n* Keep in mind that `hideCount()` method is for hiding just count, not the badge. To hide the badge, simply call `hide()`.\n\n**It isn't incrementing / decrementing properly!**\n* Any count \u003c 1 doesn't show up. If you need help customizing this, reach out to me!\n\n**The circle is in a weird place**\n* If you want to resize the circle, use `scaleCircleSize(by scale: CGFloat)`. 0.5 will give you half the size, 2 will give you double.\n* If the circle is just a few pixels off, use `moveCircleBy(x: CGFloat, y: CGFloat)`. This shifts the circle by the number of pixels given.\n* If you want to manually set the circle, call `setCircleAtFrame(_ frame: CGRect)` and give it your own CGRect.\n\n**Something else isn't working properly**\n* Use GitHub's issue reporter to submit a new issue.\n* If you think you fix that, feel free to open a pull request fixing the same.\n* Shoot me an email at jogendra.iitbhu@gmail.com.\n\n## Author\n\n\u003ctable\u003e\n\u003ctr\u003e\n\u003ctd\u003e\n\u003cimg src=\"https://avatars2.githubusercontent.com/u/20956124?s=400\u0026u=01fab3fc9bb3d2ee799e314d3fe23c54d1deeb07\u0026v=4\" width=\"180\"/\u003e\n\nJogendra Kumar\n\n\u003cp align=\"center\"\u003e\n\u003ca href = \"https://github.com/jogendra\"\u003e\u003cimg src = \"http://www.iconninja.com/files/241/825/211/round-collaboration-social-github-code-circle-network-icon.svg\" width=\"36\" height = \"36\"/\u003e\u003c/a\u003e\n\u003ca href = \"https://twitter.com/jogendrafx\"\u003e\u003cimg src = \"https://www.shareicon.net/download/2016/07/06/107115_media.svg\" width=\"36\" height=\"36\"/\u003e\u003c/a\u003e\n\u003ca href = \"https://www.linkedin.com/in/jogendrasingh24/\"\u003e\u003cimg src = \"http://www.iconninja.com/files/863/607/751/network-linkedin-social-connection-circular-circle-media-icon.svg\" width=\"36\" height=\"36\"/\u003e\u003c/a\u003e\n\u003c/p\u003e\n\u003c/td\u003e\n\u003c/tr\u003e \n\u003c/table\u003e\n\n\n## License\n\nBadgeHub is available under the MIT license. See the [LICENSE](LICENSE) file for more info.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjogendra%2FBadgeHub","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjogendra%2FBadgeHub","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjogendra%2FBadgeHub/lists"}