PMAlertController is a great and customizable alert that can substitute UIAlertController

Overview

Icon

Language GitHub license Pod version Carthage Compatible Downloads

PMAlertController is a small library that allows you to substitute Apple's uncustomizable UIAlertController, with a beautiful and totally customizable alert that you can use in your iOS app. Enjoy!

Icon

Features


  • Header View
  • Header Image (Optional)
  • Title
  • Description message
  • Customizations: fonts, colors, dimensions & more
  • 1, 2 buttons (horizontally) or 3+ buttons (vertically)
  • Closure when a button is pressed
  • Text Fields support
  • Similar implementation to UIAlertController
  • Cocoapods
  • Carthage
  • Animation with UIKit Dynamics
  • Objective-C compatibility
  • Swift 4, Swift 4.2 & Swift 5 support
  • Swift Package Manager

Requirements


  • iOS 9.0+
  • Xcode 10+

CocoaPods


CocoaPods is a dependency manager for Cocoa projects. You can install it with the following command:

$ gem install cocoapods

To integrate PMAlertController into your Xcode project using CocoaPods, specify it in your Podfile:

source 'https://github.com/CocoaPods/Specs.git'
platform :ios, '9.0'
use_frameworks!

pod 'PMAlertController'

Then, run the following command:

$ pod install

Carthage


Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks.

You can install Carthage with Homebrew using the following command:

$ brew update
$ brew install carthage

To integrate PMAlertController into your Xcode project using Carthage, specify it in your Cartfile:

github "pmusolino/PMAlertController"

Run carthage update to build the framework and drag the built PMAlertController.framework into your Xcode project.

Manually


  1. Download and drop /Library folder in your project.
  2. Congratulations!

Usage


The usage is very similar to UIAlertController. PMAlertController has two styles: Alert & Walkthrough.

Alert Style: with this style, the alert has the width of 270 points, like Apple's UIAlertController.

Walkthrough Style: with walkthrough, the alert has the width of the screen minus 18 points from the left and the right bounds. This mode is intended to be used before authorization requests like the ones for location, push notifications and more.

Show a simple alert with two buttons and one textfield

//This code works with Swift 5

let alertVC = PMAlertController(title: "A Title", description: "My Description", image: UIImage(named: "img.png"), style: .alert)

alertVC.addAction(PMAlertAction(title: "Cancel", style: .cancel, action: { () -> Void in
            print("Capture action Cancel")
        }))

alertVC.addAction(PMAlertAction(title: "OK", style: .default, action: { () in
            print("Capture action OK")
        }))

alertVC.addTextField { (textField) in
            textField?.placeholder = "Location..."
        }

self.present(alertVC, animated: true, completion: nil)

Swift compatibility

Third Party Bindings

React Native

You may now use this library with React Native via the module here

Contributing

  • If you need help or you'd like to ask a general question, open an issue.
  • If you found a bug, open an issue.
  • If you have a feature request, open an issue.
  • If you want to contribute, submit a pull request.

Acknowledgements

Made with ❤️ by Paolo Musolino.

Follow me on:

💼 Linkedin

🤖 Twitter

🌇 Instagram

👨🏼‍🎤 Facebook

MIT License


PMAlertController is available under the MIT license. See the LICENSE file for more info.

Comments
  • Swift 3 Support is missing ?

    Swift 3 Support is missing ?

    Hi

    I love the library but I don't think it has Swift 3 support as Xcode 8 is telling me that I need to do a lot of changes.

    for example: //MARK: - Customizations @objc private func setShadowAlertView(){ alertView.layer.masksToBounds = false alertView.layer.shadowOffset = CGMake(0,0) and should be CGSize(width: 0, height: 0) alertView.layer.shadowRadius = 8 alertView.layer.shadowOpacity = 0.3 }

    What I'm missing ?

    bug help wanted 
    opened by YHSX88 19
  • Blackscreen when goes back to alert controller using tab bar ?

    Blackscreen when goes back to alert controller using tab bar ?

    I have 3 tab bar items with 3 different view controller. And I use PMAlertController for the first tab item, it works great but whenever I select another tab item and go back to the first one it gives black screen.

    I think it may relate to super views and order of views .

    Thanks in advance for the great library.

    screen shot 2016-12-12 at 4 08 32 pm screen shot 2016-12-12 at 4 08 47 pm screen shot 2016-12-12 at 4 08 40 pm help wanted 
    opened by fadylateef 11
  • Invalid Task Error after Pod Install

    Invalid Task Error after Pod Install

    I just installed the Pod and when I built the project I got 3 errors saying Invalid Task Strip Nib. I had to go to Build Phases and remove the PMAlertViewController.xib, and then it worked. Not sure if anyone else ran into this, but hopefully this is fixed in a future version.

    I'm running Xcode 10.1.

    Thanks, Daniel

    help wanted 
    opened by danielshaffer 9
  • Adding extra PMAlertActionStyle

    Adding extra PMAlertActionStyle

    I wanted to use PMAlertAction to imitate UIAlertController, with one difference, that is the ability to show an image above the title. However, I ran into multiple problems when trying to subclass.

    PMAlertAction is marked as an open class signing that it should be welcoming to subclassing, but the problem is for example, PMAlertActionStyle is limited to 2 cases, default and cancel but I want to imitate the behaviour of the standard UIAlertController which means I also need destructive. Even if I wanted to replace PMAlertActionStyle with my own enum, I couldn't since actionStyle is a must have for initialisation.

    In addition addSeperator and tapped are internal, so if I don't want to re-write them, I must use the convenience initialiser, which again takes a PMAlertActionStyle and is also extremely "Opinionated" about the design. I wonder what other people do? since I see no choice but forking it and replacing the enum with my own.

    It also seems to only be used in 2 places, the init to determine the titleColor and in the animateDismissWithGravity.

    I would suggest PMAlertActionStyleType should be a protocol with a var titleColor and var animationStyle. PMAlertActionStyle can confirm to it, maintaining backwards compatibility. While letting other people extend it as needed, as expected from a UI framework.

    I am of course aware that I can just crate a PMAlertAction, ignore the PMAlertActionStyle, change whatever I need in it and then return it, but it seems a little weird to do. Maybe it would make more sense if the PMAlertActionStyle had followed UIAlertController and had destructive with a default implementation the looked exactly like UIAlertController, so that a person could use a PMAlertController as plug and play replacement for for UIAlertController. However, as it stands with the yellow title and pinkish red button, it only fits into very specific designs and forces any user to customise it.

    Otherwise though, I think it's really great, and a much needed framework, with UIAlertController being so rigid.

    question 
    opened by yoavschwartz 8
  • Image not centered

    Image not centered

    Hi, I am experienced an issue.

    Now when i load the view the image is to the right not centered as before, the text is correct but not the imagen, what could be wrong?.

    thanks

    help wanted 
    opened by antonioreyna 8
  • Add header view instead image

    Add header view instead image

    A UIView is more flexible for show dynamic information besides the title and text. The height of header view could be flexible.

    Thanks for the great library!

    enhancement 
    opened by edittler 7
  • Feature Request: Dim background while presenting PMAlert

    Feature Request: Dim background while presenting PMAlert

    I tried using a different alertMaskBackground image but that didn't work for me in dismissWithBackgroudTouch = true mode. Can you suggest workaround for it or implement it in future release?

    help wanted 
    opened by sandeepbol 6
  • How to show buttons horizontally?

    How to show buttons horizontally?

    Hey!

    I'm trying to setup the buttons in a horizontal manner. Since I've 2 buttons. But I couldn't make them horizontally aligned. Any suggestions?

    extension FavoritesViewController {
        func showAddUser() {
            let alertVC = PMAlertController(title: "Add friend", description: "Please write down your friends username", image: nil, style: .alert)
            
            alertVC.addTextField { (textField) in
                textField?.placeholder = "Username..."
                textField?.autocorrectionType = .no
                textField?.autocapitalizationType = .none
            }
            
            alertVC.addAction(PMAlertAction(title: "Cancel", style: .cancel, action: { () in
                
            }))
            
            alertVC.addAction(PMAlertAction(title: "Add", style: .default, action: { () in
                
            }))
    
            self.present(alertVC, animated: true, completion: nil)
        }
    }
    
    help wanted 
    opened by anonrig 5
  • Added Custom Padding on Alert Description StackView

    Added Custom Padding on Alert Description StackView

    Alert Description is too close to the AlertController's ContentView when Alert Description is customized not to have a center alignment.

    Changes for this PR: Added Custom Padding on Alert Description StackView Updated Sample Project

    opened by mdflores 5
  • Alert disappear

    Alert disappear

    I think that I found a little bug

    If You Call two alert in sequence:

    First alert->ok call->second alert

    the second alert disappear immediately and block the app with the only maskbackground visible.

    If you delay the second alert call this don't happen.

    Hope that my explanation is clear.

    bug 
    opened by MattiaConfalonieri 5
  • Black background when using Tabbar

    Black background when using Tabbar

    Hello Paolo,

    I detected a problem when using PMAlert on a Tabbed Application. When I change the tab with the alert and then returning to the controller the background is black. The problem, however, is only when the view has a navigation controller, otherwise not. The same situation with the UIAlert does not present the problem. How can I fix it?

    Thank you in advance Peppe

    Simulator Screen Shot - iPhone Xʀ - 2019-06-08 at 14 47 59

    help wanted 
    opened by grosetti 4
  • Missing SPM Support

    Missing SPM Support

    If anyone is interested in SPM support, my fork here has it working with Xcode 12.2 and Swift 5.3.

    I wiped out support for Carthage and Cocoapods to simplify things which I why I didn't open a PR. @pmusolino if you are interested in merging this support in, I wouldn't mind running the last mile and restoring support for the functionality I removed with my quick implementation.

    opened by Sidetalker 3
  • App Store Connect operation error

    App Store Connect operation error

    Using latest Carthage version, Xcode 12.0.1 (12A7300). When sending out app for distribution on App Store, i get ITMS-90056 and ITMS-90057 errors:

    • missing CFBundleVersion and CFBundleShortVersionString in Info.plist

    *** TEMP WORKAROUND: add manually those two keys into PMAlertController's Info.plist

    opened by crasholo 0
  • How to customize like fonts?

    How to customize like fonts?

    README says it is customizable but don't see an option. For example, action label font is hardcoded as "Avenir-Heavy". I can always do:

    let okAction = PMAlertAction(title: "OK", style: .default, action: { () in
                print("Capture action OK")
            })
    okAction.titleLabel?.font = ... my font ...
    

    Are there other ways without looking into the code

    opened by saravr 0
  • Option to have light/dark statusBarStyle with PMAlertController

    Option to have light/dark statusBarStyle with PMAlertController

    Added option in the constructor to define whether or not you want the statusBarStyle to be white or default. Because when you have you iOS app with light status bar and the PMAlertController popups it changes to default (black), with this fix is optional to the user.

    opened by josmanperez 0
  • Display two alertVC

    Display two alertVC

    I want to open another alertVC when you click a button, like a conformation type system. I implemented it like this

    alertVC.addAction(PMAlertAction(title: "Delete", style: .default, action: { () in
       let conformation = PMAlertController(title: "Really delete this post?", description: nil, image: nil, style: .alert)
       conformation.addAction(PMAlertAction(title: "Yes", style: .default, action: { () in
          print("Capture action OK")
       }))
       TapticEngine.impact.feedback(.light)
       self.getTopMostViewController()?.present(conformation, animated: false, completion: nil)
    }))
    

    This does not work and doesn't show the controller. Any ideas how can I achieve this?

    opened by Daksh14 0
Releases(4.0.1)
  • 4.0.1(Sep 7, 2020)

  • 4.0.0(Mar 27, 2019)

    • Support for Swift 5 and Xcode 10.2
    • Added alert content stack view and alert style properties + validations to hide the title and description labels if the passed strings are nil https://github.com/pmusolino/PMAlertController/pull/82
    • Allow custom text fields to be added. https://github.com/pmusolino/PMAlertController/pull/76
    Source code(tar.gz)
    Source code(zip)
  • 3.5.0(Sep 23, 2018)

    • Support for Swift 4.2 and Xcode 10 https://github.com/pmusolino/PMAlertController/pull/71
    • Allow objective-c classes to access gravityDismissAnimation & dismissWithBackgroudTouch https://github.com/pmusolino/PMAlertController/pull/70
    Source code(tar.gz)
    Source code(zip)
  • 3.4.0(Apr 22, 2018)

    • Now the alert has new custom paddings https://github.com/pmusolino/PMAlertController/pull/61
    • Added React Native module in readme https://github.com/pmusolino/PMAlertController/pull/62
    Source code(tar.gz)
    Source code(zip)
  • 3.3.0(Apr 10, 2018)

  • 3.2.0(Jan 16, 2018)

    Now the PMAlertAction callback is called after that the alert was dismissed.

    References:

    • https://github.com/Codeido/PMAlertController/issues/56
    Source code(tar.gz)
    Source code(zip)
  • 3.1.0(Dec 12, 2017)

  • 3.0.0(Sep 25, 2017)

  • 2.1.3(Aug 29, 2017)

  • 2.1.2(Mar 29, 2017)

  • 2.1.1(Mar 21, 2017)

    Now is possible to dismiss an alert with a background tap. This feature is disabled by default, so no worries for standard usage.

    References: https://github.com/Codeido/PMAlertController/pull/38

    Source code(tar.gz)
    Source code(zip)
  • 2.1.0(Jan 18, 2017)

    PMAlertController now supports Text Fields! :confetti_ball:

    Add a text field is really simple

    alertVC.addTextField { (textField) in
                textField?.placeholder = "Location..."
            }
    

    References: https://github.com/Codeido/PMAlertController/pull/27 https://github.com/Codeido/PMAlertController/pull/34

    Source code(tar.gz)
    Source code(zip)
  • 2.0.1(Oct 1, 2016)

  • 2.0.0(Sep 18, 2016)

    Swift 3.0 and Xcode 8 support.

    Changes: This new version now use a header view instead of image, that is more flexible for show dynamic information besides the title and text. The old imageview is now contained inside the header view.

    • alertImageHeightConstraint has been replaced by headerViewHeightConstraint

    References: https://github.com/Codeido/PMAlertController/issues/14 https://github.com/Codeido/PMAlertController/issues/15

    Source code(tar.gz)
    Source code(zip)
  • 1.1.0(Sep 14, 2016)

  • 1.0.5(Aug 3, 2016)

    Now alertStackViewHeightConstraint is public. See this pull request for more info: https://github.com/Codeido/PMAlertController/pull/21

    NB: this release use Swift 2.2.

    Source code(tar.gz)
    Source code(zip)
  • 1.0.4(May 27, 2016)

  • 1.0.3(May 22, 2016)

  • 1.0.2(May 21, 2016)

  • 1.0.1(May 19, 2016)

Owner
Paolo Musolino
Full remote iOS Software Engineer with more than 8 years of experience in the iOS platform. Heart and soul in every line of code.
Paolo Musolino
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
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
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
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.

donggyu 5 Jan 26, 2022
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
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.

Ali Samaiee 11 Jun 6, 2022
Customizable replacement for UIAlertController

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

Horizontal Systems 0 Oct 6, 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
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 Simple Customizable Alert With Swift

SimpleCustomizableAlert trying to make my very first library. Support Title Message (TextView) Image TextField Button Action Example let alert

null 1 Oct 26, 2021
JAlert - This is "Alert View" project for UIKit + SwiftUI. you can use easily

JAlert Example To run the example project, clone the repo, and run pod install from the Example directory first. Requirements Installation JAlert is a

Jackson 3 Feb 22, 2022
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,

Gabriel Alvarado 736 Nov 3, 2022
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
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
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
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
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

Roland Moers 1.2k Dec 13, 2022