Skip to content

jinSasaki/AlertBar

Repository files navigation

AlertBar

Version License Platform Carthage compatible

An easy alert on status bar.

Demo
demo

Usage

Import

import AlertBar

Show alert message

AlertBar has default types:

  • success
  • error
  • notice
  • warning
  • info
AlertBar.show(type: .success, message: "This is a Success message.")

And you can customize the background and text colors of AlertBar.
Select custom type and set background and text colors as UIColor: .custom(BackgroundColor, TextColor)

AlertBar.show(type: .custom(.lightGray, .black), message: "This is a Custom message.")

Alert duration

AlertBar accepts to custom alert duration.

AlertBar.show(type: .success, message: "This is a Success message.", duration: 10)

AlertBar Options

AlertBar accepts options follows:

  • Consider Safe Area
  • Stretch bar
  • TextAlignment

Use setDefault method to set default options.

let options = AlertBar.Options(
    shouldConsiderSafeArea: true, 
    isStretchable: true, 
    textAlignment: .center,
    font: UIFont.systemFont(ofSize: 14.0, weight: .medium)
)
AlertBar.setDefault(options: options)

Or set parameter of show method to each AlertBar.

let options = AlertBar.Options(
    shouldConsiderSafeArea: true, 
    isStretchable: true, 
    textAlignment: .center,
    font: UIFont.systemFont(ofSize: 14.0, weight: .medium)
)
AlertBar.show(type: .success, message: "This is AlertBar!", options: options)

Consider Safe Area

The Safe Area is adopted from iOS 11 and AlertBar can change whether to consider SafeArea or not.

AlertBar.Options#shouldConsiderSafeArea: Bool is set to true by default.

shouldConsiderSafeArea == true shouldConsiderSafeArea == false
true false

Stretch bar

AlertBar can stretch the bar if the message needs the multi lines.

AlertBar.Options#isStretchable: Bool is set to false by default.

isStretchable == true isStretchable == false
true false

TextAlignment

AlertBar accepts to custom text alignment.

Installation

CocoaPods

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

pod "AlertBar"

Carthage

AlertBar is available through Carthage since 0.3.1. To install it, simply add the following line to your Cartfile:

github "jinSasaki/AlertBar"

Author

Jin Sasaki, sasakky_j@gmail.com

License

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