- July 11, 2025
- Mins Read
There are various ways you can add BadgeSwift to your Xcode project.
Add source (iOS 7+)
Simply add BadgeSwift.swift file to your project.
Alternatively, add github "evgenyneu/swift-badge" ~> 8.0
to your Cartfile and run carthage update
.
If you are using CocoaPods add this text to your Podfile and run pod install
.
use_frameworks!
target ‘Your target name’
pod ‘BadgeSwift’, ‘~> 8.0’
Setup a previous version of the library if you use an older version of Swift.
class
to BadgeSwift
in identity inspector.module
property to BadgeSwift
(unless you used the file setup method).Note: Carthage setup method does not allow to customize Cosmos view from the storyboard, please do it from code instead.
Add import BadgeSwift
to your source code unless you used the file setup method.
let badge = BadgeSwift()
view.addSubview(badge)
// Position the badge …
See example of how to create and position the badge from code in the demo app.
// Text
badge.text = “2”
// Insets
badge.insets = CGSize(width: 12, height: 12)
// Font
badge.font = UIFont.preferredFont(forTextStyle: UIFontTextStyle.body)
// Text color
badge.textColor = UIColor.yellow
// Badge color
badge.badgeColor = UIColor.black
// Shadow
badge.shadowOpacityBadge = 0.5
badge.shadowOffsetBadge = CGSize(width: 0, height: 0)
badge.shadowRadiusBadge = 1.0
badge.shadowColorBadge = UIColor.black
// No shadow
badge.shadowOpacityBadge = 0
// Border width and color
badge.borderWidth = 5.0
badge.borderColor = UIColor.magenta
// Customize the badge corner radius.
// -1 if unspecified. When unspecified, the corner is fully rounded. Default: -1.
badge.cornerRadius = 10
This project includes a demo app.
A SwiftUI View that emits confetti with user-defined shapes, images, and text.
A colour wheel made all in SwiftUI. There are 2 different colour wheels to choose from. The first main one ...
A color picker implementation with color wheel appearance written in plain SwiftUI. It is compatible with UIColor and NSColor.
This repository is no longer maintained. Here's why: with the release of iOS 16 SwiftUI now enables most of the ...