📜  swift alert toast - Swift (1)

📅  最后修改于: 2023-12-03 15:05:25.680000             🧑  作者: Mango

Swift Alert Toast

Swift Alert Toast is a lightweight and easy-to-use library for displaying customizable toast messages in your iOS applications. With just a few lines of code, you can add beautiful and informative toast messages to your app.

Features
  • Easy to use API
  • Customizable toast messages
  • Support for both top and bottom positioning
  • Automatic dismissal after a set duration
  • Support for iOS dark mode
Installation

Swift Alert Toast can be easily installed via Cocoapods. Add the following line to your Podfile:

pod 'SwiftAlertToast'

Then run pod install in your terminal.

Usage

To display a toast message, simply call the showToast method on any view:

self.view.showToast(message: "Hello, world!")

By default, the toast will be displayed at the bottom of the screen and will disappear after 2 seconds. You can customize this behavior by passing additional parameters to the showToast method:

self.view.showToast(message: "Hello, world!", position: .top, duration: 3.0)

You can also customize the appearance of the toast by setting properties on the SwiftAlertToast singleton:

SwiftAlertToast.shared.backgroundColor = UIColor.red
SwiftAlertToast.shared.textColor = UIColor.white
SwiftAlertToast.shared.font = UIFont.systemFont(ofSize: 16.0)
Conclusion

Swift Alert Toast is a simple yet powerful library for adding toast messages to your iOS app. With its easy-to-use API and customizable appearance, it is a great choice for developers of all skill levels. Give it a try in your next project!