Bedgeable is a protocol can display badge into your any custom UI components or even apply all UIView.
Xcode
File > Swift Packages > Add Package Dependency
Enter https://github.com/millenagm/Badgeable.git
in the "Choose Package Repository" dialog.
If you prefer to install manually.
- Drop
Badgeable.swift
file into your Xcode project.
Conform Badgeable
protocol where you want to display badge.
Then you can display badge by setting badgeCount
property.
class CustomButton: UIButton, Badgable { }
or by extension
extension UIView: Badgeable {}
You can change the appearance.
view.badgeCount = 6
view.maxValue = 5 // will show (5+)
view.badgeColor = .orange
view.badgePosition = .topRight