## Overview
GrStatusBar is a customizable status bar component for iOS, designed to provide a versatile solution for displaying status messages and alerts within your application.
It offers a range of features, including:
– Customizable appearance
– Support for different status types (success, warning, error)
– Different display modes (animated, static)
– Smooth transitions between status changes
– Flexible positioning options
– Ability to dismiss or auto-hide the status bar
## Installation
Before installing GrStatusBar, ensure you have the following prerequisites set up:
– Xcode 11.0 or later
– iOS 11.0 or later
– Cocoapods
### CocoaPods
To install GrStatusBar using [CocoaPods](https://cocoapods.org), simply add the following line to your `Podfile`:
“`
pod ‘GrStatusBar’
“`
Next, add the following import statement to the class where you want to use GrStatusBar:
“`
import GrStatusBar
“`
## Getting Started
To use GrStatusBar, you need to initialize it with a frame and add it to your view hierarchy. You can customize the appearance and configure other settings as desired.
### Initialization
To initialize GrStatusBar, use the following code:
“`
let statusBar = GrStatusBar(frame: CGRect(x: 0, y: 0, width: self.view.frame.width, height: 40))
“`
### Adding to View Hierarchy
To add GrStatusBar as a subview to your main view, use the following code:
“`
self.view.addSubview(statusBar)
“`
## Customization
GrStatusBar provides various options for appearance customization. You can modify properties such as background color, font, text color, and animation duration.
### Example
To customize the background color of GrStatusBar, use the following code:
“`
statusBar.backgroundColor = UIColor.lightGray
“`
### Available Customization Options
GrStatusBar provides the following customization options:
– `backgroundColor`: Allows you to set the background color of GrStatusBar.
– `textColor`: Allows you to set the text color of GrStatusBar.
– `font`: Allows you to set the font of GrStatusBar.
– `animationDuration`: Allows you to set the duration of status bar appearance animations.
## Usage
GrStatusBar allows you to display different types of status messages using various methods. The supported types are success, warning, and error.
### Displaying Success Status
To display a success status message, use the following code:
“`
statusBar.showSuccess(withMessage: “Task completed successfully!”)
“`
### Displaying Warning Status
To display a warning status message, use the following code:
“`
statusBar.showWarning(withMessage: “Proceed with caution!”)
“`
### Displaying Error Status
To display an error status message, use the following code:
“`
statusBar.showError(withMessage: “An error occurred!”)
“`
## Transition Modes
GrStatusBar supports both animated and static transition modes when changing between different status types. The animation mode provides a smooth transition effect.
### Setting the Transition Mode
To set the transition mode for GrStatusBar, use the following code:
“`
statusBar.transitionMode = .animated // or .static
“`
## Positioning
GrStatusBar allows you to position the status bar at the top or bottom of the screen, depending on your requirements.
### Setting the Position
To set the position of GrStatusBar, use the following code:
“`
statusBar.position = .top // or .bottom
“`
## Dismissal
GrStatusBar provides two ways to dismiss or auto-hide the status bar: manual dismissal and auto-dismissal after a specified duration.
### Manual Dismissal
To dismiss the status bar manually, use the following code:
“`
statusBar.dismiss()
“`
### Auto-Dismissal
To enable auto-dismissal and set the duration for GrStatusBar, use the following code:
“`
statusBar.autoDismissDuration = 3.0 // Specify the duration in seconds
“`