Badgeable 0.1.2

Badgeable 0.1.2

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Jan 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Daniel KIM.




Badgeable 0.1.2

  • By
  • Daniel KIM

Badgeable

Badgeable

Bedgeable is a protocol can display badge into your any custom UI components or even apply all UIView.

Requirements

  • iOS 8.0+
  • Xcode 8.0+
  • Swift 3.0+

Installation

Manually

If you prefer to install manually.

  • Clone Badgeable
  • Copy Badgeable.swift file into your Xcode project.
  • That’s it!

Usage

Add import syntax where you would conform Badgeable protocol.

import Badgeable

Conform Badgeable protocol where you want to display badge.

// Conform Badgeable protocol in your class.
class YourButton: UIButton, Badgeable {
    // ...
}

Then you can display badge by setting badgeCount property.

class YourViewController: UIViewController {
    @IBOutlet weak var button: YourButton!
    override func viewDidLayoutSubviews() {
        super.viewDidLayoutSubviews()
        button.badgeCount = 6
    }
}

You can conform Badgeable protocol even UIView by extension.

// Conformance Badgeable into UIView
extension UIView: Badgeable {}

Then all UI components can display badge by setting badgeCount property.

TODO

  • Configurable badge appearance.
  • Adjustable badge position. For example: TopLeft, TopRight, BottomLeft and BottomRight.
  • Animatable.

Author

Daniel (Dae Hyun) KIM, [email protected]

License

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