BadgedBarButtonItem icon indicating copy to clipboard operation
BadgedBarButtonItem copied to clipboard

UIBarButtonItem with a customizable badge for iOS applications

BadgedBarButtonItem

UIBarButtonItem with a customizable badge for iOS applications

Instructions to use:

  1. Add BadgedBarButtonItem class to your project

  2. Create a new object with your image:

    let btn = BadgedButtonItem(with: UIImage(named: "your_image"))
  1. Add the button to the navigation bar
    self.navigationItem.rightBarButtonItem = btn
  1. Customise badge appearance
  • Set a tint color btn.badgeTintColor = .blue

  • Set a text color btn.badgeTextColor = .green

  • Set badge position (left or right) btn.position = .left

  • Add a border to the badge btn.hasBorder = true

  • Remove a border from the badge btn.hasBorder = false

  • Set badge border color btn.borderColor = .red

  • Set bagde size btn.badgeSize = .medium

  • Set badge animation btn.badgeAnimation = true

  1. Set the badge with a value
    btn.setBadge(with: 1)
  1. Add an action to the button
    btn.tapAction = {
    // do something
        
    }