Swift Package mimicking UIKit's ActionSheet with added features

Overview

ActionSheetController

A Swift package that mimics the UIAlertController Actionsheet with added features.

ActionSheetController gives you the ability to add extra features like custom views, images, custom view actions and headers to your UIAlertController not originally available out of the box.

Platforms supported:

  • iOS 13+

Adding to your project

Follow Apple's guidance to add the package to your project through SPM.

Usage

Basic usage

Basic ActionSheetController. Directly mimics the UIAlertController Actionsheet

import ActionSheetController

let alert = ActionSheetController(title: "Backup Data", message: "How often do you want to backup your data?")
alert.addAction(title: "Daily", type: .normal, action: {
    // Backup Daily
})
alert.addAction(title: "Weekly", type: .normal, action: {
    // Backup Weekly
})
alert.addAction(title: "Monthly", type: .normal, action: {
    // Backup Monthly
})
alert.addAction(title: "Never", type: .destructive, action: nil)
alert.launch()

ActionSheetController with done action

ActionSheetController with addAction . Replaces the Cancel text with a custom title and an action to be performed if needed

let alert = ActionSheetController(title: "Log Session", message: "Do you want to continue logging your session?")
alert.addAction(title: "Yes", type: .normal, action: nil)
alert.addAction(title: "No", type: .normal, action: nil)
alert.addDoneAction(title: "Ask me later", type: .normal) {
    //Perform Action
}
alert.launch()

ActionSheetController with header view

ActionSheetController with addHeader(view: UIView) . Adds a custom header to the ActionSheetController

let block: UIView = {
    let view = UIView()
    view.layer.cornerRadius = 50
    view.backgroundColor = .yellow
    view.heightAnchor.constraint(equalToConstant: 100).isActive = true
    view.widthAnchor.constraint(equalToConstant: 100).isActive = true
    view.translatesAutoresizingMaskIntoConstraints = false
    return view
}()

let alert = ActionSheetController(title: "Yellow Header Here", message: "Awesome!")
alert.addHeader(view: block)
alert.launch()

let block: UIView = {
    let view = UIView()
    view.layer.cornerRadius = 50
    view.backgroundColor = .yellow
    view.heightAnchor.constraint(equalToConstant: 100).isActive = true
    view.widthAnchor.constraint(equalToConstant: 100).isActive = true
    view.translatesAutoresizingMaskIntoConstraints = false
    return view
}()

let alert = ActionSheetController(title: "Yellow Header Here", message: "Awesome!")
alert.addAction(title: "Yes", type: .normal, action: nil)
alert.addAction(title: "No", type: .normal, action: nil)
alert.addHeader(view: block)
alert.launch()

ActionSheetController with customAction view

ActionSheetController with addCustomAction(view: UIView) . Adds a custom action view to the ActionSheetController

let textfield: UITextField = {
    let view = UITextField()
    view.borderStyle = .bezel
    view.placeholder = "Enter contact name"
    view.widthAnchor.constraint(equalToConstant: 300).isActive = true
    view.translatesAutoresizingMaskIntoConstraints = false
    return view
}()

let alert = ActionSheetController(title: "Edit Contact", message: "Enter new contact name")
alert.addCustomAction(view: textfield)
alert.addAction(title: "Cancel", type: .normal, action: nil)
alert.addDoneAction(title: "Save", type: .normal, action: {
    let name = textfield.text
    //Save contact
})
alert.launch()

let slider: UISlider = {
    let view = UISlider(frame: .zero)
    view.widthAnchor.constraint(equalToConstant: 300).isActive = true
    view.translatesAutoresizingMaskIntoConstraints = false
    return view
}()
let alert = ActionSheetController(title: "Background Opacity", message: "Drag slider to adjust opacity")
alert.addCustomAction(view: slider)
alert.addAction(title: "Cancel", type: .normal, action: nil)
alert.addDoneAction(title: "Save", type: .normal, action: {
    //Save
})
alert.launch()

ActionSheetController with header image

ActionSheetController with addHeader(image: UIImage?, size: Size? = nil, cornerRadius: CGFloat? = nil, title: String?, message: String?) . Adds a custom header image to the ActionSheetController

let alert = ActionSheetController(title: nil, message: nil)
alert.addHeader(image: UIImage(named: "pic"), cornerRadius: 50, title: "John Doe", message: "iOS Developer")
alert.addAction(title: "Follow", type: .normal, action: nil)
alert.addAction(title: "Unfollow", type: .destructive, action: nil)
alert.launch()

let alert = ActionSheetController(title: nil, message: nil)
alert.addHeader(image: UIImage(named: "success-2"), title: "Yay!", message: "You've opened the app for 3 consecutive days")
alert.addAction(title: "Claim Reward", type: .normal, action: {
    //Claim Reward
})
alert.launch()

You might also like...
A Swift library to provide a bouncy action sheet
A Swift library to provide a bouncy action sheet

Hokusai is a Swift library that provides a bouncy action sheet. It will give the users a fancy experience without taking pains coding the cool animati

Simple UIAlertController builder class in Swift.
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

A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style.
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

Beautiful animated Alert View. Written in Swift
Beautiful animated Alert View. Written in Swift

SCLAlertView Animated Alert View written in Swift, which can be used as a UIAlertView or UIAlertController replacement. Since UIAlertView is deprecate

Live animated Alert View for iOS written in Swift
Live animated Alert View for iOS written in Swift

Sweet Alert iOS Beautiful Animated custom Alert View inspired from javascript library SweetAlert. Written in Swift this SweetAlertView can be used in

A Swift library to design custom prompts with a great scope of options to choose from.
A Swift library to design custom prompts with a great scope of options to choose from.

Installation CocoaPods Install with CocoaPods by adding the following to your Podfile: source 'https://github.com/CocoaPods/Specs.git' platform :ios,

SwiftOverlays is a Swift GUI library for displaying various popups and notifications
SwiftOverlays is a Swift GUI library for displaying various popups and notifications

SwiftOverlays is a Swift GUI library for displaying various popups and notifications. SwiftOverlays animated logo is kindly made by Crafted Pixels Fea

Lightweight dropdown message bar in Swift. It's simple and beautiful.
Lightweight dropdown message bar in Swift. It's simple and beautiful.

SwiftyDrop SwiftyDrop is a lightweight pure Swift simple and beautiful dropdown message. Features Easy to use like: Drop.down("Message") Message field

Fully customizable and extensible action sheet controller written in Swift
Fully customizable and extensible action sheet controller written in Swift

XLActionController By XMARTLABS. XLActionController is an extensible library to quickly create any custom action sheet controller. Examples The action

Owner
Adebiyi Mojisola
iOS Developer
Adebiyi Mojisola
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

Daiki Okumura 406 Sep 5, 2022
Customizable simple Alert and simple ActionSheet for Swift

SimpleAlert It is simple and easily customizable alert. Can be used as UIAlertController. Appetize's Demo Requirements Swift 5.0 iOS 9.0 or later How

Kyohei Ito 397 Dec 6, 2022
A Swift package for iOS/tvOS for easy alert presentation

AlertPresenter Listed on the Swift Package Index and originally posted on my blog. It can be fiddly to handle the presentation of alerts on a specific

Chris Mash 14 Jul 1, 2022
CoffeeToast - A swift package to easily add Toast notifications to your app

CoffeeToast A simple Swift package to add Toast Notifications to your app. Insta

Maegan Wilson 2 Feb 3, 2022
Package for creating, modifying, and managing subtitle files, such as SubRip (.srt).

SubtitleKit Package for creating, modifying, and managing subtitle files, such as SubRip (.srt). Supported formats Format File extension Is supported

GGorAA 2 Oct 28, 2022
Swift library to manage in app notification in swift language, like WhatsApp, Telegram, Frind, ecc.

InAppNotify - Manage in App notifications During develop of my app Frind, I needed to manage in app notifications like whatsapp or telegram, but i did

Luca Becchetti 438 Nov 20, 2022
Ipraktikum-swift-solutions - The solutions of the easy entrance swift quiz for the IPraktikum

ipraktikum-swift-solutions The solutions of the easy entrance swift quiz for the

Eugenio Berretta 0 Feb 13, 2022
Highly customizable alertview and alert/notification/success/error/alarm popup written in Swift

CDAlertView is highly customizable alert popup written in Swift. Usage is similar to UIAlertController. Screenshots Animations Usage Basic usage witho

Candost Dagdeviren 1.1k Dec 30, 2022
Easy Swift UIAlertController

EZAlertController Easy Swift UIAlertController One line setup for all UIAlertControllers Button action with closures instead of selectors Easily custo

Kan Yilmaz 366 Sep 14, 2022
A simple style messages/notifications, in Swift.

Demo Example To show notifications use the following code: self.showMessage("Something success", type: .success) To display a notice on a view: view.s

Gesen 704 Dec 17, 2022