All Projects → jogendra → Badgehub

jogendra / Badgehub

Licence: mit
A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.

Programming Languages

swift
15916 projects

Projects that are alternatives of or similar to Badgehub

Loadingshimmer
An easy way to add a shimmering effect to any view with just one line of code. It is useful as an unobtrusive loading indicator.
Stars: ✭ 1,180 (+99.32%)
Mutual labels:  hacktoberfest, swift-framework, xcode, cocoapods, animations
Countrypicker
A simple, customizable Country picker for picking country or dialing code. 🇮🇳 🇯🇵 🇰🇷 🇩🇪 🇨🇳 🇺🇸 🇫🇷 🇪🇸 🇮🇹 🇷🇺 🇬🇧
Stars: ✭ 174 (-70.61%)
Mutual labels:  hacktoberfest, xcode, cocoapods
Luexpandabletableview
A subclass of UITableView with expandable and collapsible sections
Stars: ✭ 125 (-78.89%)
Mutual labels:  xcode, cocoapods, pod
Flightanimator
Advanced Natural Motion Animations, Simple Blocks Based Syntax
Stars: ✭ 588 (-0.68%)
Mutual labels:  swift-framework, xcode, animations
Swiftlyext
SwiftlyExt is a collection of useful extensions for Swift 3 standard classes and types 🚀
Stars: ✭ 31 (-94.76%)
Mutual labels:  swift-framework, xcode, cocoapods
Nextgrowingtextview
📝 The next in the generations of 'growing textviews' optimized for iOS 8 and above.
Stars: ✭ 1,540 (+160.14%)
Mutual labels:  hacktoberfest, xcode, cocoapods
Swiftinstagram
Instagram API client written in Swift
Stars: ✭ 570 (-3.72%)
Mutual labels:  swift-framework, xcode, cocoapods
Downloader For Apple Developers
Download Xcode, WWDC Videos, and other developer tools up to 16 times faster.
Stars: ✭ 456 (-22.97%)
Mutual labels:  hacktoberfest, xcode
Pulltodismiss
You can dismiss modal viewcontroller like Facebook Messenger by pulling scrollview or navigationbar in Swift.
Stars: ✭ 456 (-22.97%)
Mutual labels:  swift-framework, cocoapods
Dnspageview
一个纯 Swift 的轻量级、灵活且易于使用的 pageView
Stars: ✭ 461 (-22.13%)
Mutual labels:  xcode, cocoapods
Ttsegmentedcontrol
An elegant, animated and customizable segmented control for iOS created by Tapptitude
Stars: ✭ 471 (-20.44%)
Mutual labels:  xcode, cocoapods
React Native Mixpanel
A React Native wrapper for Mixpanel tracking
Stars: ✭ 451 (-23.82%)
Mutual labels:  xcode, notifications
Hero
Elegant transition library for iOS & tvOS
Stars: ✭ 20,547 (+3370.78%)
Mutual labels:  xcode, animations
Uitextfield Navigation
🏄‍♂️ UITextField-Navigation makes it easier to navigate between UITextFields and UITextViews
Stars: ✭ 436 (-26.35%)
Mutual labels:  xcode, cocoapods
Mylinearlayout
MyLayout is a powerful iOS UI framework implemented by Objective-C. It integrates the functions with Android Layout,iOS AutoLayout,SizeClass, HTML CSS float and flexbox and bootstrap. So you can use LinearLayout,RelativeLayout,FrameLayout,TableLayout,FlowLayout,FloatLayout,PathLayout,GridLayout,LayoutSizeClass to build your App 自动布局 UIView UITab…
Stars: ✭ 4,152 (+601.35%)
Mutual labels:  xcode, cocoapods
Example Ios Apps
 A curated list of Open Source example iOS apps developed in Swift. An amazing list for people who are beginners and learning ios development and for ios developers who need any example app or feature.
Stars: ✭ 461 (-22.13%)
Mutual labels:  hacktoberfest, xcode
Progresskit
Progress Views for Cocoa
Stars: ✭ 510 (-13.85%)
Mutual labels:  xcode, cocoapods
Gedatsu
Gedatsu provide readable format about AutoLayout error console log
Stars: ✭ 464 (-21.62%)
Mutual labels:  xcode, cocoapods
Xcake
🍰 Describe Xcode projects in a human readable format and (re)generate one on demand.
Stars: ✭ 549 (-7.26%)
Mutual labels:  xcode, cocoapods
Bow
🏹 Bow is a cross-platform library for Typed Functional Programming in Swift
Stars: ✭ 538 (-9.12%)
Mutual labels:  hacktoberfest, cocoapods

BadgeHub

A way to quickly add a notification badge icon to any view.

CI Status Version License Platform Buy me a Coffee

Blink Bump Pop Custom setCircle showCount mix hideCount

Demo/Example

For demo:

$ pod try BadgeHub

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

$ cd Example
$ pod install

If you don't have CocoaPods installed, grab it with [sudo] gem install cocoapods.

$ open BadgeHub.xcworkspace

Requirements

  • iOS 10.0 or later
  • Swift 5+
  • Xcode 10+

Installation

CocoaPods

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

pod 'BadgeHub'

Manual Installation

Just drag the BadgeHub.swift files into your project.

Usage

Initialization.

let hub = BadgeHub(view: yourView) // Initially count set to 0

Initializer for setting badge to bar button items.

let hub = BadgeHub(barButtonItem: UIBarButtonItem)

Increase count value by 1.

hub.increment()

Increase count by some int value.

hub.increment(by: Int)

Decrease count value by 1.

hub.decrement()

Decrease count by some int value.

hub.decrement(by: Int)

Set count to static integer value.

hub.setCount(newCount: Int)

Get value of current count on badge.

hub.getCurrentCount() // returns Int value of current count.

Combine actions

mix

hub.increment()
hub.pop()
hub.blink()

Don't forget to import BadgeHub

Customization

Change the color of the notification circle, also the text color of count label.

setCircleColor

hub.setCircleColor(_ circleColor: UIColor?, label labelColor: UIColor?)

Change the border color and border width of the circle

Custom

hub.setCircleBorderColor(_ color: UIColor?, borderWidth width: CGFloat)

Set the frame of the notification badge circle relative to the view.

setCircle

hub.setCircleAtFrame(_ frame: CGRect)

Move the circle (left/right or up/down).

hub.moveCircleBy(x: CGFloat, y: CGFloat)

Changes the size of the circle. setting a scale of 1 has no effect.

hub.scaleCircleSize(by scale: CGFloat)

Hide the count (Blank Badge). Keep in mind that this method is for hiding just count, not the badge.

hideCount

hub.hideCount()

Show count again on the badge.

showCount

hub.showCount()

Hide the badge from your view.

hub.hide()

Show again the badge. Badge will staye hidden even after calling this method, if current count on badge is <= 0.

hub.show()

Set 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).

hub.setMaxCount(to: Int)

Set the font of the count label.

hub.setCountLabelFont(_ font: UIFont?)

Get the current font set on the count label.

hub.getCountLabelFont()

Set alpha to badge.

hub.setAlpha(alpha: CGFloat)

Animations

Pop out and pop in the badge.

Pop

hub.pop()

Make badge blinking.

Blink

hub.blink()

Animation that jumps similar to macOS dock icons.

Bump

hub.bump()

TROUBLESHOOTING

Notification isn't showing up!

  • If the hub value is < 1, the circle hides. Try calling increment().
  • Make sure the view you set the hub to is visible (i.e. did you call self.view.addSubview(yourView)?).
  • Make sure you didn't call hideCount() anywhere. Call showCount() to counter this.

Badge is not hiding even after setting value to 0

  • Make sure you are setting zero count on correct BadgeHub instance.
  • Try calling checkZero() method after setting count to 0.
  • Varify if current count is <= 0 by calling getCurrentCount() method.
  • Keep in mind that hideCount() method is for hiding just count, not the badge. To hide the badge, simply call hide().

It isn't incrementing / decrementing properly!

  • Any count < 1 doesn't show up. If you need help customizing this, reach out to me!

The circle is in a weird place

  • 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.
  • 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.
  • If you want to manually set the circle, call setCircleAtFrame(_ frame: CGRect) and give it your own CGRect.

Something else isn't working properly

  • Use GitHub's issue reporter to submit a new issue.
  • If you think you fix that, feel free to open a pull request fixing the same.
  • Shoot me an email at [email protected].

Author

Jogendra Kumar

BUY ME A COFFEE?

If you loved my work, Buy me a Coffee here:

Buy Me A Coffee

License

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

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].