TOAlertViewController

TOAlertViewController is a flexible and customizable alert view controller library for iOS, written in Swift. It provides an easy-to-use interface and advanced customization options to create beautiful and engaging alert views in your iOS app.

Features

  • Customizable design with various alert styles
  • Support for multiple buttons, text fields, and custom views
  • Predefined alert styles for common use cases
  • Option to add a title, message, and image to the alert
  • Ability to handle button actions with closures
  • Interactive presentation and dismissal animations
  • Dynamic font sizing for accessibility support

Installation

You can install TOAlertViewController using CocoaPods. Simply add the following line to your Podfile:

pod 'TOAlertViewController'

Usage

1. Import the TOAlertViewController module:

import TOAlertViewController

2. Create an instance of TOAlertViewController:

let alert = TOAlertViewController(title: "Alert Title", message: "Alert Message", style: .alert)

3. Customize the alert if needed:

alert.addAction(TOAlertAction(title: "OK", style: .default, handler: { _ in
    // Handle button action
}))
alert.addAction(TOAlertAction(title: "Cancel", style: .cancel, handler: nil))
// Add more actions if required

// Optional customizations:
// alert.addTextField(configurationHandler: { textField in
    // Configure text field
// })
// alert.imageView?.image = UIImage(named: "alertImage")

// You can also use predefined alert styles:
// alert.setPredefinedStyle(.success)
// alert.setPredefinedStyle(.warning)
// alert.setPredefinedStyle(.error)

4. Present the alert:

present(alert, animated: true, completion: nil)

Requirements

  • iOS 10.0+
  • Xcode 10.0+
  • Swift 4.2+

License

TOAlertViewController is released under the MIT License. See GitHub for more details.