Skip to content

Hartistic/Alert

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

41 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Swift 5.0+ Platform: iOS XCode 11+ iOS 13 Licence MIT

Alert

Alert is a customizable alert that acts like the native UIAlertController.
Alert's layout, styling, and sizing is easy to change. The main feature of Alert is its queue, that instead of canceling other incoming alerts (like UIAlertController does) will show the next one when the first alert is dismissed. It does this by showing a small red badge in the upper right hand corner.

Usage

Download the example project from this repo to see how simple Alert is to use.

In the App Delegate, register the observer under didFinishLaunchingWithOptions:

Alert.shared.setupAlertChangeObserver()
  • Simple Alert
let alert = AlertViewController(image: nil, title: "Error Occurred", subtitle: "Image failed to download")
let dismissButton = AlertButton.dismiss(handler: nil)
alert.buttons = [dismissButton]
Alert.shared.addAlert(alert, on: self)
  • Simple Alert + Rounded Button:
let alert = AlertViewController(image: nil, title: "Error Occurred", subtitle: "Image failed to download")
let dismissButton = AlertButton.dismiss(handler: nil)
alert.buttons = [dismissButton]
alert.buttonHeight = 40
alert.cornerRadius = 20
Alert.shared.addAlert(alert, on: self)
  • Simple Alert + Multiple Buttons + Rounded:
let alert = AlertViewController(image: nil, title: "Error Occurred", subtitle: "Image failed to download")
let yesButton = AlertButton.yes(handler: nil)
let noButton = AlertButton.no(handler: nil)
alert.buttons = [noButton, yesButton]
alert.buttonHeight = 40
alert.cornerRadius = 20
Alert.shared.addAlert(alert, on: self)
  • Vertical Buttons:
alert.buttonLayout = .vertical
  • Change Vibrancy Background Color:
alert.vibrancyColor = .red
  • Title & Subtitle Font:
alert.titleFont = UIFont.systemFont(ofSize: 40, weight: .bold)
alert.subtitleFont = UIFont.systemFont(ofSize: 20, weight: .bold)
  • Title & Subtitle Color:
alert.titleColor = .blue
alert.subtitleColor = .green

Releases

No releases published

Packages

No packages published

Languages