TestsTested | ✗ |
LangLanguage | SwiftSwift |
License | MIT |
ReleasedLast Release | Sep 2017 |
SwiftSwift Version | 3.0 |
SPMSupports SPM | ✓ |
Maintained by Merrick Sapsford.
A flexible and simple to use SnackBar view for iOS.
CocoaBar is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'CocoaBar'
Swift 2.1 support is available in version 0.1.7 or below:
pod 'CocoaBar', '~> 0.1.0'
And run pod install
.
CocoaBar can be attached to a view or window.
public init(window: UIWindow?)
public init(view: UIView?)
The CocoaBar can then be shown or hidden using the showAnimated
or hideAnimated
functions. There are numerous convenience functions available for showing the CocoaBar to allow for easy customisation. They provide the following:
Double
or DisplayDuration
; which provides a preset time period to display the bar for.CocoaBarLayout
layout to display.When a CocoaBar is attached to the keyWindow
, it is made available as the keyCocoaBar
. showAnimated
and hideAnimated
class functions are then available on CocoaBar
for the keyCocoaBar
.
Custom layouts can be displayed in a CocoaBar with the use of a CocoaBarLayout
subclass.
CocoaBarLayout
will automatically attempt to inflate a nib associated with the layout (using the same class name), and use AutoLayout to calculate the required dimensions. init(nibName, height)
is also available to manually specify the nib to use and set an explicit height. Refer to the example project to see usage of a custom layout.
The following properties are available to customise on a CocoaBarLayout:
cocoaBar(cocoaBar: actionButtonPressed actionButton:)
being called for the CocoaBarDelegate
.Supports iOS 8 and above.
Merrick Sapsford