A customizable 🍞 toast notification library for iOS, built with Swift!
- Show beautiful toast messages in your app!
- Highly customizable: colors, fonts, padding, corner radius, button, and more 🎨
- Supports positioning: top, center, or bottom 🧭
- Add a button for user interaction (optional) 🖱️
- Easy animation and auto-dismissal ⏰
- Built with UIKit, supports iOS 15+ 📱
Add ToastKit to your project using Swift Package Manager:
dependencies: [
.package(url: "https://github.com/lcaxgg/ToastKit.git", from: "1.0.0")
]Or use Xcode:
- Go to File > Add Packages...
- Enter:
https://github.com/lcaxgg/ToastKit - Add the package to your project!
You can easily extend ToastAttributes to create your own custom initializer for more streamlined usage!
import ToastKit
extension ToastAttributes {
static func customInit(
contentInsets: UIEdgeInsets = .zero,
containerInsets: UIEdgeInsets = .zero,
cornerRadius: CGFloat = 0,
backgroundColor: UIColor = .black,
foregroundColor: UIColor = .white,
titleMessageSpacing: CGFloat = 0,
title: String? = nil,
message: String,
showButton: Bool = false,
titleFont: UIFont = UIFont.systemFont(ofSize: 0, weight: .bold),
messageFont: UIFont = UIFont.systemFont(ofSize: 0),
buttonText: String = "Button",
buttonTextFont: UIFont = UIFont.systemFont(ofSize: 0),
position: ToastPosition = .bottom,
positionOffset: CGFloat = 0,
duration: TimeInterval = 0,
deadline: CGFloat = 0
) -> ToastAttributes {
return ToastAttributes(
contentInsets: contentInsets,
containerInsets: containerInsets,
cornerRadius: cornerRadius,
backgroundColor: backgroundColor,
foregroundColor: foregroundColor,
title: title,
message: message,
titleFont: titleFont,
messageFont: messageFont,
titleMessageSpacing: titleMessageSpacing,
buttonText: buttonText,
buttonTextFont: buttonTextFont,
showButton: showButton,
position: position,
positionOffset: positionOffset,
duration: duration,
deadline: deadline
)
}
}Here’s how you can use your custom initializer to show a toast:
let attributes = ToastAttributes.customInit(
title: "Title here",
message: "message here",
showButton: true
)
view.showToastMessage(with: attributes, onButtonTap: {
print("Button tapped!")
})| Simple Toast | Toast with Button |
|---|---|
|
|
Contributions, issues, and feature requests are welcome!
Feel free to check issues page.

