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.
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.
Increments the counter by one (does not perform upper bounds checking).
myBadgeView.incrementCounter()
Decrements the counter by one (will stop at zero).
myBadgeView.decrementCounter()
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.
- Changing the anchor point of a layer without making the layer’s location jump (
NSView
extention, seeNSView+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.
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'
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 © 2020 Mike Manzo. Released under the MIT License.