Latest 0.3.0
Homepage https://github.com/MerrickSapsford/CocoaBar
License MIT
Platforms ios 8.0
Authors

CocoaBar

Build Status
CocoaPods
Swift 4

A flexible and simple to use SnackBar view for iOS.

Requirements

CocoaBar requires iOS 9 or above, and Swift 3.

Installation

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

pod 'CocoaBar'

And run pod install.

Usage

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:

  • Duration – either a Double or DisplayDuration; which provides a preset time period to display the bar for.
  • Layout – provide a custom CocoaBarLayout layout to display.
  • Style – use one of the predefined layouts for 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.

Customisation

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:

  • backgroundStyle – customise the appearance of the layout background.
  • displayStyle – customise the display appearance of the layout.
  • keylineColor – the colour of the 1pt keyline at the top of the layout.
  • dismissButton – attach to a button that serves purely for dismissal of the CocoaBar.
  • actionButton – attach to a button that serves as an action button for the layout. Interaction will result in the cocoaBar(cocoaBar: actionButtonPressed actionButton:) being called for the CocoaBarDelegate.

Requirements

Supports iOS 8 and above.

Author

Merrick Sapsford

sapsford.tech
@MerrickSapsford
[email protected]

Latest podspec

{
    "name": "CocoaBar",
    "version": "0.3.0",
    "summary": "Snackbar for iOS.",
    "description": "A flexible and simple to use SnackBar view for iOS.",
    "homepage": "https://github.com/MerrickSapsford/CocoaBar",
    "screenshots": [
        "https://raw.githubusercontent.com/MerrickSapsford/CocoaBar/develop/Resource/screenshot1.png",
        "https://raw.githubusercontent.com/MerrickSapsford/CocoaBar/develop/Resource/screenshot2.png"
    ],
    "license": "MIT",
    "authors": {
        "Merrick Sapsford": "[email protected]"
    },
    "social_media_url": "http://twitter.com/MerrickSapsford",
    "platforms": {
        "ios": "8.0"
    },
    "source": {
        "git": "https://github.com/MerrickSapsford/CocoaBar.git",
        "tag": "0.3.0"
    },
    "source_files": [
        "CocoaBar",
        "Sources/**/*.{swift}"
    ],
    "resources": [
        "Sources/**/*.{xib}"
    ],
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This