Generate a "badge" (circular label) for any view and place it in the center or any corner of a given view
Badge Generator uses a lightweight, easy to understand approach to make a circular UILabel with the given text
- platform: iOS
- extends: UIView
- @discardableResult public func setBadge(in direction: BadgeDirection, with text: String) -> BadgeLabel
- adds a new badge to the view in the given location (BadgeDirection)
- adds a new badge to the view in the given location (BadgeDirection)
- @discardableResult public func setBadge(in direction: BadgeDirection, with text: String) -> BadgeLabel
In your Xcode project, simply go to File -> Swift Packages -> Add Package Dependency. Then use this repo's URL: https://github.com/froggomad/BadgeGenerator
let myView = UIView()
let badge = myView.setBadge(in: .northWest, with: "1")
badge.incrementIntValue(by: 1)
let value = badge.incrementIntValue(by: 1)
switch value {
case let .success(intValue):
print(intValue)
case let .failure(error):
print(error)
}
badge.set("foo")
badge.remove()
These badges are placed on a PreviewProvider
, but you can place them on any UIView or in SwiftUI using UIViewRepresentable
If you notice a bug, or think of a feature you'd like to add, please read our Contributor's Guide