iOS custom badge button.

Overview

MIBadgeButton

MIBadgeButton is badge button written in Swift with high UITableView/UICollectionView performance.

Screenshots

alt tag

Installation

MIBadgeButton is available through CocoaPods, to install it simply add the following line to your Podfile:

# Swift 3
use_frameworks!
pod "MIBadgeButton-Swift", :git => 'https://github.com/mustafaibrahim989/MIBadgeButton-Swift.git', :branch => 'master'

# Swift 2
use_frameworks!
pod "MIBadgeButton-Swift", :git => 'https://github.com/mustafaibrahim989/MIBadgeButton-Swift.git', :branch => 'swift2'

Add MIBadgeButton to Storyboard or init with frame

button.badgeString = "120"

Set EdgeInsets to change the default position of the badge (Optional)

button.badgeEdgeInsets = UIEdgeInsetsMake(10, 0, 0, 15)

Change the badge text color and background color

button.badgeTextColor = UIColor.blueColor()
button.badgeBackgroundColor = UIColor.redColor()

Author

Mustafa Ibrahim, [email protected]

Notes

Designed for iOS 8.

License

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

Comments
  • "Use of undeclared type MiBadgeButton"

    throwing my this error when I try to add a button to storyboard and give it the MiBadgeButton class and add an IBOutlet to it in code:

    "Use of undeclared type MiBadgeButton"

    i have tried:

    import MIBadgeButton_Swift

    but it does not seem to help.

    Any Ideas?

    opened by uknowmeright 8
  • Optional.None instead of empty string

    Optional.None instead of empty string

    Passing Optional.None instead of empty string in setupBadgeViewWithString upon initializing from Interface Builder.

    If an empty string is passed in those functions, when you initialize the badge from IB it will show an empty circle, but the badge should be hidden.

    simulator screen shot mar 23 2016 4 32 00 pm

    opened by dirtydanee 2
  • Adding badge to system UIBarButtonItem

    Adding badge to system UIBarButtonItem

    How to add badge on top of system BarButtonItem of specific style (ex. bookmarked)

    i am able to set my own image by button.setImage(UIImage(named: "filter_icon"), forState: .Normal). But how can we use system UIBarButtonSystemItem images?

    Any help!

    opened by stephen-talari 1
  • Getting warning message when installing from CocoaPods

    Getting warning message when installing from CocoaPods

    Thank you for this great work. I would like to tell you I'm getting this warning message from the terminal when I install MIBadgeButton via CocoaPods. @mustafaibrahim989

    [!] Unable to read the license file /Users/username/appname.iOS/Pods/MIBadgeButton-Swift/mit-license.txt for the spec MIBadgeButton-Swift (0.1) `

    opened by LuaiKalkatawi 1
  • iOS 9 Xcode 7.0GM issue

    iOS 9 Xcode 7.0GM issue

    Hi Mustafa,

    I am facing issue on this line, in code that you have shared:

    labelString.drawInRect(textFrame, withAttributes: attributes as [NSObject: AnyObject]) // issue is here

    Message: [NSObject: AnyObject] cannot be converted to expected type [String : AnyObject]?

    Pankaj Bansal

    opened by coolagrwal 1
  • UIBarButtonItem

    UIBarButtonItem

    It would be fantastic to have an easy way to use this on a UIBarButtonItem. Any chance you will extend it to cover this? I want to use this for a notification count indicator badge.

    opened by jedgrant 1
  • Fix xc beta6 compilation errors

    Fix xc beta6 compilation errors

    Mustafa, you have some compilation errors it think this is because you don't have the latest version of xcode (beta6), i have solved a lot of those errors, but still there are some errors in 'MIBadgeLabel', due to a change in the api that calculates the text size (sizeWithFont)

    opened by aibrahim16 1
  • Badge anchor

    Badge anchor

    -Badge now can stick to 4 different position on button here i call it anchor, these position are TopLeft, TopRight, BottomLeft, BottomRight and Center. Those anchors have offset values e.g when anchor set to TopLeft have 2 valid offset values, left and top respectively. You can either use offset value to do minor position adjustment or leave it zero which will no effect.

    "badgeEdgeInsets" property is still taking into count when calculating X Y for badge, therefore, this become 4 different options when working with badge. 1.Leave both "badgeEdgeInsets" or anchor offset to zero, this lead to badge's center been placed at 4 different position on button 2.Change "badgeEdgeInsets" to do minor adjustment 3.Change anchor offset to do minor adjustment 4.Combine "badgeEdgeInsets" with anchor offset

    -Class become designable and some properties are inspectable which mean badge's properties can be adjust in Interface Builder and visual of badge will automatically update base on those properties

    opened by tomneo2004 0
  • Fix layout breaking on bounds change

    Fix layout breaking on bounds change

    This request just adds a simple override at the bottom of the button code.
 The override makes it so the button will adjust the badge to be in the correct position when the button's bounds change. Here's the complete code changed:

    /**
        When the Button's bounds change, readjust the badge to be in the correct spot.
        This comes into play when the button is in a stack view and needs to adjust it's size, or when a constraint is changed.
    */
    open override var bounds: CGRect {
        didSet {
            setupBadgeViewWithString(badgeText: badgeString)
        }
    }
    
    opened by thecoolwinter 0
  • Can I use this with a masked button?

    Can I use this with a masked button?

    I am setting my button image to a gradient image and masking the actual button image over it, but have found that when using this process it is not showing the badge button indicator anymore. As soon as I change it back to as non masked style button it works just fine. Is there a way to use a masked button and not loose the indicator?? I can obviously use a UIView for this if necessary, but wanted to ask if you may have a solution before I went that route????

    Also, completely unrelated to the first issue, just FYI the way you have your POD setup, it forces cocoa pods to download the full version of this with every single update. Not sure if this is intended, but seems to be completely unnecessary as if there is an update it will download it automagically. Keep up the great work!!! Thank you!!!

    img_8433 img_8432

    opened by sdevo619 1
  • The statusbar overlap badge label in navigationitem iOS 11

    The statusbar overlap badge label in navigationitem iOS 11

    In iOS 10, it looks OK but in iOS 11, the statusbar overlap badge label when push navigation. Can anyone help me? Thanks Please see my image: https://i.stack.imgur.com/aCKFy.png

    opened by seasoft-phuc 4
Owner
Mustafa Ibrahim
Mustafa Ibrahim
Generate a badge for any UIView

Badge Generator 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 light

Kenny Dubroff (froggomad) 11 Jan 6, 2022
UIView extension that adds a notification badge.

Installation CocoaPods pod 'EasyNotificationBadge' Swift Package Manager You can use The Swift Package Manager to install EasyNotificationBadge by add

Antonio Zaitoun 215 Dec 11, 2022
A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.

BadgeHub A way to quickly add a notification badge icon to any view. Demo/Example For demo: $ pod try BadgeHub To run the example project, clone the r

Jogendra 773 Dec 30, 2022
zekunyan 608 Dec 30, 2022
Custom UIView class that hosts an array of UIbuttons that have an 'underline' UIView beneath them which moves from button to button when the user presses on them.

Swift-Underlined-Button-Bar Custom UIView class that hosts an array of UIbuttons that have an 'underline' UIView beneath them which moves from button

Justin Cook 3 Aug 4, 2022
A badge view for iOS/tvOS written in Swift

A badge control for iOS and tvOS written in Swift The badge is a subclass of UILabel view. It can be created and customized from the Storyboard or fro

Evgenii Neumerzhitckii 386 Dec 30, 2022
A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.

BadgeHub A way to quickly add a notification badge icon to any view. Demo/Example For demo: $ pod try BadgeHub To run the example project, clone the r

Jogendra 772 Dec 28, 2022
Generate a badge for any UIView

Badge Generator 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 light

Kenny Dubroff (froggomad) 11 Jan 6, 2022
UIView extension that adds a notification badge.

Installation CocoaPods pod 'EasyNotificationBadge' Swift Package Manager You can use The Swift Package Manager to install EasyNotificationBadge by add

Antonio Zaitoun 215 Dec 11, 2022
A way to quickly add a notification badge icon to any view. Make any view of a full-fledged animated notification center.

BadgeHub A way to quickly add a notification badge icon to any view. Demo/Example For demo: $ pod try BadgeHub To run the example project, clone the r

Jogendra 773 Dec 30, 2022
Customizable download button with progress and transition animations. It is based on Apple's App Store download button.

AHDownloadButton is a customizable download button similar to the download button in the latest version of Apple's App Store app (since iOS 11). It fe

Amer Hukić 465 Dec 24, 2022
Revamped Download Button. It's kinda a reverse engineering of Netflix's app download button.

NFDownloadButton Revamped Download Button Requirements Installation Usage License Requirements iOS 8.0+ Swift 4.2+ Xcode 10.0+ Installation CocoaPods

Leonardo Cardoso 433 Nov 15, 2022
MUDownloadButton - a Progressive Download button written in pure swift and inspired by AppStore download button

MUDownloadButton is a Progressive Download button written in pure swift and inspired by AppStore download button . feel free to contribute and pull requests

Mohammad ShahibZadeh 2 Feb 20, 2022
Hamburger Menu Button - A hamburger menu button with full customization

Hamburger Menu Button A hamburger menu button with full customization. Inspired by VinhLe's idea on the Dribble How to use it You can config the looks

Toan Nguyen 114 Jun 12, 2022
Bar Button Item that can be moved anywhere in the screen, like Android's stickers button.

FlowBarButtonItem Bar Button Item that can be moved anywhere in the screen, like Android's stickers button. [![CI Status](http://img.shields.io/travis

noppefoxwolf 153 Sep 15, 2022
Custom loading button with progress swiftui

CustomLoadingButton Simple Custom Loading Progress Button for SwiftUI Version 1.0.0 This version requires Xcode 11+ SwiftUI iOS 13+ macOS 10.15+ Insta

Tariqul 1 Dec 14, 2022
ProgressButton - Custom button class that displays a progress bar around it to gauge

ProgressButton Check it out To run the example project, clone the repo, and open the 'Example/Example.xcodeproj' file. Requirements This component is

Guilherme Moura 116 May 29, 2022
null 13 Oct 28, 2022
:octocat: AdaptiveController is a 'Progressive Reduction' Swift UI module for adding custom states to Native or Custom iOS UI elements. Swift UI component by @Ramotion

ADAPTIVE TAB BAR 'Progressive Reduction' module for adding custom states to Native or Custom UI elements. We specialize in the designing and coding of

Ramotion 2k Nov 9, 2022
Use any custom view as custom callout view for MKMapView with cool animations. Use any image as annotation view.

MapViewPlus About MapViewPlus gives you the missing methods of MapKit which are: imageForAnnotation and calloutViewForAnnotationView delegate methods.

Okhan Okbay 162 Nov 16, 2022