BadgeSegments
Example
To run the example project, clone the repo, and run pod install
from the Example directory first.
Requirements
- Swift 5
- iOS =>10
Installation
Cocoapods
BadgeSegments is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'BadgeSegments'
Manual
simply copy classes folder to your project directory
How to Use
add a UIView to your view Controller and sub class it from BadgeSegments class
@IBOutlet weak var badgeSegment: BadgeSegments!
override func viewDidLoad() {
super.viewDidLoad()
let items = [SegmentItem(title: "first",isSelected: false,badgeNumber: 20),
SegmentItem(title: "second",isSelected: true),
SegmentItem(title: "third",isSelected: false,badgeNumber: 12)]
badgeSegment.appearence = .standard
badgeSegment.delegate = self
badgeSegment.setUpSegments(with: items)
}
Delegate
class ViewController: UIViewController, BadgeSegmentDelegate {
func didSelectSegment(with index: Int) {
print(index)
}
}
Change Values
badgeSegment.setTitle(inIndex: 0, title: "changed")
badgeSegment.setSelected(inIndex: 2)
badgeSegment.setBadgeNumber(inIndex: 1, badgeNum: 12)
TO Do
- add animation
- more default appearences
- support images
- customize badge view
- add UITest and UnitTest
🇮🇷
Made with Love in Morteza Gharedaghi: [email protected]
License
BadgeSegments is available under the MIT license. See the LICENSE file for more info.