Nice and easy UIAlertController extensions

Overview

SwiftAlertController

(Inspired by EZAlertController (https://github.com/thellimist/EZAlertController))

Nice and easy UIAlertController extensions

  • One line setup for alert controllers
  • Chainable alert controller setup
  • Chainable alert actions

Installation

Just drop the SwiftAlertController.swift file into your project

Usage

Alert

// Simple alert view with an `OK` buton
UIAlertController.alert("Title") 

// Simple alert view with a additional message
UIAlertController.alert("Title", message: "Message") 

// Simple alert view with a customized action on button click
UIAlertController.alert("Title") { _ in
	print("Button clicked")
}

// Fully configurable alert view
UIAlertController.alert("Title", message: "Message", acceptMessage: "Done") { _ in
	print("Done clicked")
})

// Create a Alert with multiple buttons
UIAlertController.alert("Title")
	.action(title: "Ok") // Simple action 
	.action(title: "Do something") { _ in // Action with handler
		print("done something")
	}
	.action(title: "Destruct something", style: .destructive) { _ in // Action with handler and other style
		print("all wrecked")
	}
	.cancelable() { _ in // A Cancel button
		print("canceled")
	}

// Or use a old school array for it
UIAlertController.alert("Title", message: "Message", actions: alertAction)

// Or a closure
UIAlertController.alert("Title", message: "Message") {
	UIAlertAction(title: "Action1")
		.appending(title: "Action2")
		.appending(title: "Action3")
}

ActionSheet

// Initalize a simple ActionSheet
UIAlertController.sheet("Title")

// Initialize an ActionSheet with additional message
UIAlertController.sheet("Title", message: "Message")

// Initialize a action sheet with chaining
UIAlertController.sheet("Test")
	.action(title: "Ok")
	.action(title: "Do something") { _ in
		print("done something")
	}
	.action(title: "Destruct something", style: .destructive) { _ in
		print("all wrecked")
	}
	.cancelable() { _ in
		print("canceled")
	}

// Or use an UIAlertAction array (see how you can just drop the message)
UIAlertController.sheet("Title", actions: alertActions)

// Or use a closure for the initialization
UIAlertController.sheet("Title", message: "Message") {
	UIAlertAction(title: "Action1")
		.appending(title: "Action2")
		.appending(title: "Action3")
}

UIAlertAction

(now chainable)

// Append actions
let alertActions = UIAlertAction(title: "Action1") { _ in
	print("Action1 clicked")
}
.appending(title: "Action2") { _ in
	print("Action2 clicked")
}
.appending(title: "Action3") { _ in
	print("Action3 clicked")
}

// Initialize an UIAlertAction without the style
UIAlertAction(title: "Title") { _ in
	print("clicked")
}
You might also like...
A customizable, full-feature, lightweight iOS framework to be used instead of UIAlertController.
A customizable, full-feature, lightweight iOS framework to be used instead of UIAlertController.

A customizable, full-feature, lightweight iOS framework to be used instead of UIAlertController.

This is an iOS control for selecting a date using UIDatePicker in an UIAlertController like manner
This is an iOS control for selecting a date using UIDatePicker in an UIAlertController like manner

RMDateSelectionViewController This framework allows you to select a date by presenting an action sheet. In addition, it allows you to add actions arro

This is an iOS control for presenting any UIView in an UIAlertController like manner
This is an iOS control for presenting any UIView in an UIAlertController like manner

RMActionController This framework allows you to present just any view as an action sheet. In addition, it allows you to add actions around the present

This is an iOS control for selecting something using UIPickerView in an UIAlertController like manner
This is an iOS control for selecting something using UIPickerView in an UIAlertController like manner

RMPickerViewController This framework allows you to pick something with a picker presented as an action sheet. In addition, it allows you to add actio

Simple Alert View written in Swift, which can be used as a UIAlertController. (AlertController/AlertView/ActionSheet)
Simple Alert View written in Swift, which can be used as a UIAlertController. (AlertController/AlertView/ActionSheet)

DOAlertController Simple Alert View written in Swift, which can be used as a UIAlertController replacement. It supports from iOS7! It is simple and ea

Customizable replacement for UIAlertController

ActionSheet Customizable replacement for UIAlertController. Requirements Installation Swift Package Manager The Swift Package Manager is a tool for au

UIAlertController with continuity.

CuckooAlert Allow multiple use of presentViewController to UIAlertController. You may be disappointed from this. Do you imagine that cuckoo spit out s

Use UIAlertController like a boss.
Use UIAlertController like a boss.

Description Requirements Installation CocoaPods Carthage Usage License Description CatAlertController is a high level manager object that with chainin

A simple custom popup dialog view for iOS written in Swift. Replaces UIAlertController alert style.
A simple custom popup dialog view for iOS written in Swift. Replaces UIAlertController alert style.

A simple custom popup dialog view for iOS written in Swift. Replaces UIAlertController alert style.

Owner
zahlz
zahlz
NiceAlertView is a Swift framework that can increase time of development and show nice custom AlertsViews

NiceAlertView Nice and beautiful AlertView for your iOS project NiceAlertView is a Swift framework that can increase time of development and show nice

Daniel Beltrami 0 Nov 24, 2021
Advanced usage of UIAlertController and pickers based on it: Telegram, Contacts, Location, PhotoLibrary, Country, Phone Code, Currency, Date...

Alerts & Pickers Advanced usage of native UIAlertController with TextField, TextView, DatePicker, PickerView, TableView, CollectionView and MapView. F

RV 5.5k Dec 22, 2022
PMAlertController is a great and customizable alert that can substitute UIAlertController

PMAlertController is a small library that allows you to substitute Apple's uncustomizable UIAlertController, with a beautiful and totally customizable

Paolo Musolino 2.5k Jan 3, 2023
PMAlertController is a great and customizable alert that can substitute UIAlertController

PMAlertController is a small library that allows you to substitute Apple's uncustomizable UIAlertController, with a beautiful and totally customizable

Paolo Musolino 2.5k Jan 3, 2023
Advanced usage of UIAlertController and pickers based on it: Telegram, Contacts, Location, PhotoLibrary, Country, Phone Code, Currency, Date...

Alerts & Pickers Advanced usage of native UIAlertController with TextField, TextView, DatePicker, PickerView, TableView, CollectionView and MapView. F

RV 5.5k Dec 26, 2022
Simple and elegant way to handle UIAlertController.

SwiftyAlert SwiftAlert is simple and elegant way to handle UIAlertController. Feature Handle action with async/await Method chain Support UITextField

Jaesung Jung 2 Oct 30, 2022
Swifty, modern UIAlertController wrapper.

Alertift Alertift.alert(title: "Alertift", message: "Alertift is swifty, modern, and awesome UIAlertController wrapper.") .action(.default("❤️"))

Suguru Kishimoto 287 Jan 7, 2023
An easier constructor for UIAlertController. Present an alert from anywhere.

ALRT An easier constructor for UIAlertController. Present an alert from anywhere like this. ALRT.create(.alert, title: "Alert?").addOK().addCancel().s

Masahiro Watanabe 97 Nov 11, 2022
Simple UIAlertController builder class in Swift.

Kamagari Simple UIAlertController builder class in Swift. Features AlertBuilder class to simply build UIAlertController by using method chaining UIAle

Kazunobu Tasaka 78 Nov 29, 2022
A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style.

Introduction Popup Dialog is a simple, customizable popup dialog written in Swift. Features Easy to use API with hardly any boilerplate code Convenien

Orderella Ltd. 3.8k Dec 20, 2022