Skip to content

An NSView-based unread badge count control for macOS with support for designables and inspectables in Interface Builder.

License

Notifications You must be signed in to change notification settings

MikeManzo/Badger

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

33 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

BadgerView Framework

Status GitHub code size in bytes GitHub last commit GitHub All Releases Swift

An NSView-based unread badge count control for macOS based on Aral Balkan's BadgeView. Benefits include playing well with auto layout and support for designables and inspectables in Interface Builder.

API

count

Gets/sets the count to an interger value.

myBadgeView.count = 42

Set count to zero to hide the badge view and to any non-zero integer to show it.

incrementCounter()

Increments the counter by one (does not perform upper bounds checking).

myBadgeView.incrementCounter()

decrementCounter()

Decrements the counter by one (will stop at zero).

myBadgeView.decrementCounter()

Auto-Alignment

When using the auto-alignment feature, you must set one placeholder constraint on the Badge View. This is to avoid Xcode automatically adding prototyping constraints to the view and interfering with the alignment algorithms.

Odds & Ends

  • Changing the anchor point of a layer without making the layer’s location jump (NSView extention, see NSView+ChangeAnchorPointWithoutMakingTheLayerJump.swift)
  • Using tags in custom NSViews
  • A category that easily lets you calculate the length (in points) of a string in a given font (see NSFont+WidthOfString.swift)
  • Using @IBDesignable and @IBInspectable to create custom components that you can customise using Interface Builder.
  • Uses the Cartography library for setting up Auto Layout constraints declaratively.

Installation

CocoaPods

CocoaPods is a dependency manager for Cocoa projects. For usage and installation instructions, visit their website. To integrate Alamofire into your Xcode project using CocoaPods, specify it in your Podfile:

pod 'Badger', '~> 0.9.0'

Debugging

In some instances, the IBDesignable will fail to render in Interface Builder. If that is the case, try adding the following to your podfile for post-install processing:

post_install do |installer|
  installer.pods_project.build_configurations.each do |config|
    config.build_settings['LD_RUNPATH_SEARCH_PATHS'] = [
      '$(FRAMEWORK_SEARCH_PATHS)'
    ]
  end
end

Copyright & License Information

Copyright © 2020 Mike Manzo. Released under the MIT License.

About

An NSView-based unread badge count control for macOS with support for designables and inspectables in Interface Builder.

Resources

License

Stars

Watchers

Forks

Packages

No packages published