AlertViewCustom

4.0.0

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.
jadebowl/AlertViewCustom

What's New

4.0.0

2023-11-21T13:52:52Z

Added:

  • Possibility to change Font
  • Possibility to have the Agree Button Outlined
  • SwiftLint

SPM compatible Version License

Codacy Badge

AlertViewCustom

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.

Features

  • 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

Latest Updates:

  • Possibility to change Font
  • Possibility to have the Agree Button Outlined

Examples

Bottom & No Title Font Custom Icon & Color One Button
Position & No Title Font Custom Icon & Color One Button
Outlined Button
Outlined Button & View Radius

Installation

Swift Package Manager

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.

CocoaPods

AlertViewCustom is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'AlertViewCustom'

Manually

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.

Usage

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)
    }
}

Contributing

Contributions are very welcome 🙌

Description

  • Swift Tools 5.8.0
View More Packages from this Author

Dependencies

  • None
Last updated: Thu Apr 04 2024 12:13:18 GMT-0900 (Hawaii-Aleutian Daylight Time)