With AlertViewCustom you can create your own customised UIAlertView instead of using the default one from Apple, which doesn't always fit in with the style of your app.
- Can be used both in UIKit and SwiftUI
- Add Icon
- Personalise Title, Message and both Buttons
- Possibility to hide Title, Message and Cancel Button
- Change Alert Position (.center or .bottom)
- Change Agree Button Corner Radius
- Change Agree Button Color
- Change View Background Color
- Change Corner Radius of the whole AlertView
- Add Animation from the Bottom when in .bottom Position
- Possibility to change Font
- Possibility to have the Agree Button Outlined
Bottom & No Title | Font Custom | Icon & Color | One Button |
---|---|---|---|
Outlined Button | |||
To integrate using Apple's Swift Package Manager, add the following as a dependency to your Package.swift
:
dependencies: [
.package(url: "https://github.com/jadebowl/AlertViewCustom.git", from: "4.0.0")
]
Alternatively navigate to your Xcode project, select Swift Packages
and click the +
icon to search for AlertViewCustom
.
AlertViewCustom is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'AlertViewCustom'
If you prefer not to use any of the aforementioned dependency managers, you can integrate AlertViewCustom into your project manually. Simply drag the Sources
Folder into your Xcode project.
Create an Alert:
import AlertViewCustom
var alert = AlertView()
Customise the UI and add the Fade transition:
let agreeButton = AgreeButton(title: "Go to Settings")
let alertSettings = AlertSettings(accentColor: .systemBlue,
backgroundColor: .systemBackground,
icon: UIImage(systemName: "hand.wave"),
title: "I am a title",
message: "Lorem ipsum dolor sit amet, consectetuadipiscing elit, sed do eiusmod tempor incididunt ulabore et dolore magna aliqua.",
agreeButton: agreeButton,
cancelTitle: "Cancel",
position: .bottom(animated: true))
alert.setupContents(delegate: self, settings: alertSettings)
alert.fadeIn(duration: 0.3)
Manage Actions:
extension Controller: AlertViewDelegate {
func agreeAction() {
// MARK: - Example: Go to Settings
guard let settingsUrl = URL(string: UIApplication.openSettingsURLString) else { return }
if UIApplication.shared.canOpenURL(settingsUrl) {
UIApplication.shared.open(settingsUrl, completionHandler: { (success) in
print("Settings opened: \(success)")
})
}
}
func cancelAction() {
alert.removeFromSuperView(duration: 0.3)
}
}
Contributions are very welcome 🙌