A simple, customizable popup dialog for iOS written in Swift. Replaces UIAlertController alert style.

Overview

 

Swift Version Version License Platform Carthage compatible Build Status Master Build Status Development Reviewed by Hound

 

Introduction

Popup Dialog is a simple, customizable popup dialog written in Swift.

Features

  • Easy to use API with hardly any boilerplate code
  • Convenient default view with image, title, message
  • Supports custom view controllers
  • Slick transition animations
  • Fully themeable via appearance, including fonts, colors, corner radius, shadow, overlay color and blur, etc.
  • Can be dismissed via swipe and background tap
  • Objective-C compatible
  • Works on all screens and devices supporting iOS 10.0+

 

Installation

This version is Swift 5 compatible. For the Swift 4.2 version, please use V1.0.0.

CocoaPods

PopupDialog is available through CocoaPods. Simply add the following to your Podfile:

use_frameworks!

target '<Your Target Name>'
pod 'PopupDialog', '~> 1.1'

Carthage

Carthage is a decentralized dependency manager that builds your dependencies and provides you with binary frameworks. A minimum version of 0.17 is required.

To install, simply add the following lines to your Cartfile:

github "Orderella/PopupDialog" ~> 1.1

Manually

If you prefer not to use either of the above mentioned dependency managers, you can integrate PopupDialog into your project manually by adding the files contained in the Classes folder to your project. Moreover, you have to manually add the classes of DynamicBlurView to your project.

 

Example

You can find this and more example projects in the repo. To run it, clone the repo, and run pod install from the Example directory first.

import PopupDialog

// Prepare the popup assets
let title = "THIS IS THE DIALOG TITLE"
let message = "This is the message section of the popup dialog default view"
let image = UIImage(named: "pexels-photo-103290")

// Create the dialog
let popup = PopupDialog(title: title, message: message, image: image)

// Create buttons
let buttonOne = CancelButton(title: "CANCEL") {
    print("You canceled the car dialog.")
}

// This button will not the dismiss the dialog
let buttonTwo = DefaultButton(title: "ADMIRE CAR", dismissOnTap: false) {
    print("What a beauty!")
}

let buttonThree = DefaultButton(title: "BUY CAR", height: 60) {
    print("Ah, maybe next time :)")
}

// Add buttons to dialog
// Alternatively, you can use popup.addButton(buttonOne)
// to add a single button
popup.addButtons([buttonOne, buttonTwo, buttonThree])

// Present dialog
self.present(popup, animated: true, completion: nil)

 

Usage

PopupDialog is a subclass of UIViewController and as such can be added to your view controller modally. You can initialize it either with the handy default view or a custom view controller.

Default Dialog

public convenience init(
    title: String?,
    message: String?,
    image: UIImage? = nil,
    buttonAlignment: UILayoutConstraintAxis = .vertical,
    transitionStyle: PopupDialogTransitionStyle = .bounceUp,
    preferredWidth: CGFloat = 340,
    tapGestureDismissal: Bool = true,
    panGestureDismissal: Bool = true,
    hideStatusBar: Bool = false,
    completion: (() -> Void)? = nil) 

The default dialog initializer is a convenient way of creating a popup with image, title and message (see image one and three).

Bascially, all parameters are optional, although this makes no sense at all. You want to at least add a message and a single button, otherwise the dialog can't be dismissed, unless you do it manually.

If you provide an image it will be pinned to the top/left/right of the dialog. The ratio of the image will be used to set the height of the image view, so no distortion will occur.

Custom View Controller

public init(
    viewController: UIViewController,
    buttonAlignment: UILayoutConstraintAxis = .vertical,
    transitionStyle: PopupDialogTransitionStyle = .bounceUp,
    preferredWidth: CGFloat = 340,
    tapGestureDismissal: Bool = true,
    panGestureDismissal: Bool = true,
    hideStatusBar: Bool = false,
    completion: (() -> Void)? = nil) 

You can pass your own view controller to PopupDialog (see image two). It is accessible via the viewController property of PopupDialog, which has to be casted to your view controllers class to access its properties. Make sure the custom view defines all constraints needed, so you don't run into any autolayout issues.

Buttons are added below the controllers view, however, these buttons are optional. If you decide to not add any buttons, you have to take care of dismissing the dialog manually. Being a subclass of view controller, this can be easily done via dismissViewControllerAnimated(flag: Bool, completion: (() -> Void)?).

Button Alignment

Buttons can be distributed either .horizontal or .vertical, with the latter being the default. Please note distributing buttons horizontally might not be a good idea if you have more than two buttons.

public enum UILayoutConstraintAxis : Int {
	case horizontal
	case vertical
}

Transition Style

You can set a transition animation style with .bounceUp being the default. The following transition styles are available

public enum PopupDialogTransitionStyle: Int {
    case bounceUp
    case bounceDown
    case zoomIn
    case fadeIn
}

Preferred Width

PopupDialog will always try to have a max width of 340 . On iPhones with smaller screens, like iPhone 5 SE, width would be 320. 340 is also the standard width for iPads. By setting preferredWidth you can override the max width of 340 for iPads only.

Gesture Dismissal

Gesture dismissal allows your dialog being dismissed either by a background tap or by swiping the dialog down. By default, this is set to true. You can prevent this behavior by setting either tapGestureDismissal or panGestureDismissal to false in the initializer.

Hide Status Bar

PopupDialog can hide the status bar whenever it is displayed. Defaults to false. Make sure to add UIViewControllerBasedStatusBarAppearance to Info.plist and set it to YES.

Completion

This completion handler is called when the dialog was dismissed. This is especially useful for catching a gesture dismissal.

 

Default Dialog Properties

If you are using the default dialog, you can change selected properties at runtime:

// Create the dialog
let popup = PopupDialog(title: title, message: message, image: image)

// Present dialog
self.present(popup, animated: true, completion: nil)

// Get the default view controller and cast it
// Unfortunately, casting is necessary to support Objective-C
let vc = popup.viewController as! PopupDialogDefaultViewController

// Set dialog properties
vc.image = UIImage(...)
vc.titleText = "..."
vc.messageText = "..."
vc.buttonAlignment = .horizontal
vc.transitionStyle = .bounceUp

 

Styling PopupDialog

Appearance is the preferred way of customizing the style of PopupDialog. The idea of PopupDialog is to define a theme in a single place, without having to provide style settings with every single instantiation. This way, creating a PopupDialog requires only minimal code to be written and no "wrappers".

This makes even more sense, as popup dialogs and alerts are supposed to look consistent throughout the app, that is, maintain a single style.

Dialog Default View Appearance Settings

If you are using the default popup view, the following appearance settings are available:

let dialogAppearance = PopupDialogDefaultView.appearance()

dialogAppearance.backgroundColor      = .white
dialogAppearance.titleFont            = .boldSystemFont(ofSize: 14)
dialogAppearance.titleColor           = UIColor(white: 0.4, alpha: 1)
dialogAppearance.titleTextAlignment   = .center
dialogAppearance.messageFont          = .systemFont(ofSize: 14)
dialogAppearance.messageColor         = UIColor(white: 0.6, alpha: 1)
dialogAppearance.messageTextAlignment = .center

Dialog Container Appearance Settings

The container view contains the PopupDialogDefaultView or your custom view controller. the following appearance settings are available:

let containerAppearance = PopupDialogContainerView.appearance()

containerAppearance.backgroundColor = UIColor(red:0.23, green:0.23, blue:0.27, alpha:1.00)
containerAppearance.cornerRadius    = 2
containerAppearance.shadowEnabled   = true
containerAppearance.shadowColor     = .black
containerAppearance.shadowOpacity   = 0.6
containerAppearance.shadowRadius    = 20
containerAppearance.shadowOffset    = CGSize(width: 0, height: 8)
containerAppearance.shadowPath      = CGPath(...)

Overlay View Appearance Settings

This refers to the view that is used as an overlay above the underlying view controller but below the popup dialog view. If that makes sense ;)

let overlayAppearance = PopupDialogOverlayView.appearance()

overlayAppearance.color           = .black
overlayAppearance.blurRadius      = 20
overlayAppearance.blurEnabled     = true
overlayAppearance.liveBlurEnabled = false
overlayAppearance.opacity         = 0.7

Note

Setting liveBlurEnabled to true, that is enabling realtime updates of the background view, results in a significantly higher CPU usage /power consumption and is therefore turned off by default. Choose wisely whether you need this feature or not ;)

Button Appearance Settings

The standard button classes available are DefaultButton, CancelButton and DestructiveButton. All buttons feature the same appearance settings and can be styled separately.

var buttonAppearance = DefaultButton.appearance()

// Default button
buttonAppearance.titleFont      = .systemFont(ofSize: 14)
buttonAppearance.titleColor     = UIColor(red: 0.25, green: 0.53, blue: 0.91, alpha: 1)
buttonAppearance.buttonColor    = .clear
buttonAppearance.separatorColor = UIColor(white: 0.9, alpha: 1)

// Below, only the differences are highlighted

// Cancel button
CancelButton.appearance().titleColor = .lightGray

// Destructive button
DestructiveButton.appearance().titleColor = .red

Moreover, you can create a custom button by subclassing PopupDialogButton. The following example creates a solid blue button, featuring a bold white title font. Separators are invisible.

public final class SolidBlueButton: PopupDialogButton {

    override public func setupView() {
        defaultFont           = .boldSystemFont(ofSize: 16)
        defaultTitleColor     = .white
        defaultButtonColor    = .blue
        defaultSeparatorColor = .clear
        super.setupView()
    }
}

These buttons can be customized with the appearance settings given above as well.

 

Dark mode example

The following is an example of a Dark Mode theme. You can find this in the Example project AppDelegate, just uncomment it to apply the custom appearance.

// Customize dialog appearance
let pv = PopupDialogDefaultView.appearance()
pv.titleFont    = UIFont(name: "HelveticaNeue-Light", size: 16)!
pv.titleColor   = .white
pv.messageFont  = UIFont(name: "HelveticaNeue", size: 14)!
pv.messageColor = UIColor(white: 0.8, alpha: 1)

// Customize the container view appearance
let pcv = PopupDialogContainerView.appearance()
pcv.backgroundColor = UIColor(red:0.23, green:0.23, blue:0.27, alpha:1.00)
pcv.cornerRadius    = 2
pcv.shadowEnabled   = true
pcv.shadowColor     = .black

// Customize overlay appearance
let ov = PopupDialogOverlayView.appearance()
ov.blurEnabled     = true
ov.blurRadius      = 30
ov.liveBlurEnabled = true
ov.opacity         = 0.7
ov.color           = .black

// Customize default button appearance
let db = DefaultButton.appearance()
db.titleFont      = UIFont(name: "HelveticaNeue-Medium", size: 14)!
db.titleColor     = .white
db.buttonColor    = UIColor(red:0.25, green:0.25, blue:0.29, alpha:1.00)
db.separatorColor = UIColor(red:0.20, green:0.20, blue:0.25, alpha:1.00)

// Customize cancel button appearance
let cb = CancelButton.appearance()
cb.titleFont      = UIFont(name: "HelveticaNeue-Medium", size: 14)!
cb.titleColor     = UIColor(white: 0.6, alpha: 1)
cb.buttonColor    = UIColor(red:0.25, green:0.25, blue:0.29, alpha:1.00)
cb.separatorColor = UIColor(red:0.20, green:0.20, blue:0.25, alpha:1.00)

I can see that there is room for more customization options. I might add more of them over time.

 

Screen sizes and rotation

Rotation and all screen sizes are supported. However, the dialog will never exceed a width of 340 points on iPhones. For iPads, you can set preferredWidth when initializing a new PopupDialog. However, landscape mode will not work well if the height of the dialog exceeds the width of the screen.

 

Working with text fields

If you are using text fields in your custom view controller, popup dialog makes sure that the dialog is positioned above the keyboard whenever it appears. You can opt out of this behaviour by setting keyboardShiftsView to false on a PopupDialog.

Testing

PopupDialog exposes a nice and handy method that lets you trigger a button tap programmatically:

public func tapButtonWithIndex(_ index: Int)

Other than that, PopupDialog unit tests are included in the root folder.

 

Objective-C

PopupDialog can be used in Objective-C projects as well. Here is a basic example:

PopupDialog *popup = [[PopupDialog alloc] initWithTitle: @"Title"
                                                message: @"This is a message"
                                                  image: nil
                                        buttonAlignment: UILayoutConstraintAxisVertical
                                        transitionStyle: PopupDialogTransitionStyleBounceUp
                                         preferredWidth: 380
                                    tapGestureDismissal: NO
                                    panGestureDismissal: NO
                                          hideStatusBar: NO
                                             completion: nil];

DestructiveButton *delete = [[DestructiveButton alloc] initWithTitle: @"Delete"
                                                              height: 45
                                                        dismissOnTap: YES
                                                              action: nil];

CancelButton *cancel = [[CancelButton alloc] initWithTitle: @"Cancel"
                                                    height: 45
                                              dismissOnTap: YES
                                                    action: nil];

DefaultButton *ok = [[DefaultButton alloc] initWithTitle: @"OK"
                                                  height: 45
                                            dismissOnTap: YES
                                                  action: nil];

[dialog addButtons:@[delete, cancel, ok]];

[self presentViewController:popup animated:YES completion:nil];

 

Bonus

Shake animation

If you happen to use PopupDialog to validate text input, for example, you can call the handy shake() method on PopupDialog.

 

Requirements

Minimum requirement is iOS 10.0. This dialog was written with Swift 5, for support of older versions please head over to releases.

 

Changelog

  • 1.1.1 Updates dependencies to Swift 5
  • 1.1.0 Swift 5 support
  • 1.0.0 Pinned Swift version to 4.2
    Dropped iOS 9 support as of moving to ios-snapshot-test-case
  • 0.9.2 Fixes crash when presenting dialog while app is inactive
  • 0.9.1 Fixes Carthage support
  • 0.9.0 Swift 4.2 support
  • 0.8.1 Added shadow appearance properties
  • 0.8.0 Separated tap and pan gesture dismissal
  • 0.7.1 Fixes Objective-C compatability
    Improved Carthage handling
  • 0.7.0 Removed FXBlurView while switching to DynamicBlurView
  • 0.6.2 Added preferredWidth option for iPads
  • 0.6.1 Added shake animation
    Introduced hideStatusBar option
  • 0.6.0 Swift 4 support
    Dropped iOS8 compatibility
  • 0.5.4 Fixed bug where blur view would reveal hidden layer
    Improved view controller lifecycle handling
    Scroll views can now be used with gesture dismissal
  • 0.5.3 Fixed memory leak with custom view controllers
    Added UI automation & snapshot tests
  • 0.5.2 Fixed image scaling for default view
  • 0.5.1 Introduced custom button height parameter
    Reintroduced iOS8 compatibility
  • 0.5.0 Swift 3 compatibility / removed iOS8
  • 0.4.0 iOS 8 compatibility
  • 0.3.3 Fixes buttons being added multiple times
  • 0.3.2 Dialog repositioning when interacting with keyboard
    Non dismissable buttons option
    Additional completion handler when dialog is dismissed
  • 0.3.1 Fixed Carthage issues
  • 0.3.0 Objective-C compatibility
  • 0.2.2 Turned off liveBlur by default to increase performance
  • 0.2.1 Dismiss via background tap or swipe down transition
  • 0.2.0 You can now pass custom view controllers to the dialog. This introduces breaking changes.
  • 0.1.6 Defer button action until animation completes
  • 0.1.5 Exposed dialog properties
    (titleText, messageText, image, buttonAlignment, transitionStyle)
  • 0.1.4 Pick transition animation style
  • 0.1.3 Big screen support
    Exposed basic shadow appearance
  • 0.1.2 Exposed blur and overlay appearance
  • 0.1.1 Added themeing example
  • 0.1.0 Intitial version

 

Author

Martin Wildfeuer, [email protected] for Orderella Ltd., orderella.co.uk
You might also want to follow us on Twitter, @theMWFire | @Orderella

Thank you

Thanks to everyone who uses, enhances and improves this library, especially the contributors. Moreover, thanks to KyoheiG3 for porting FXBlurView to DynamicBlurView.

 

License

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

Comments
  • Crash when present a popup which inited by a View Controller

    Crash when present a popup which inited by a View Controller

    Environment

    My development environment

    • Xcode version (e.g. 9.1): 9.4.1
    • PopupDialog version (e.g. 0.5.0): 0.7.1 , 0.8.1
    • Language Swift 4.1

    Pices of Code

    let dialog = PopupDialog(viewController: confirmVC, buttonAlignment: .vertical, transitionStyle: .bounceUp, gestureDismissal: false, completion: nil) present(dialog, animated: true, completion: nil)

    wontfix 
    opened by thuongdao 32
  • Custom popupDialog breaks when VC is presented above it

    Custom popupDialog breaks when VC is presented above it

    @mwfire I copied the custom xib from the example and place it in my project. I removed all the stuff in it and replaced it with a tableView displaying my contact list. It works perfectly at this point. When a cell accessory is tapped, I present the MFMessageComposeViewController. When that gets dismissed, my popup dialogue completely breaks. Here are the photos in action sequence.

    What could it be?😂

    screen shot 2016-09-18 at 11 59 11 pm screen shot 2016-09-18 at 11 59 38 pm

    I noticed that as the MessagesComposeViewController is being presented, popup dialogue is pushed to the top left. screen shot 2016-09-18 at 11 59 47 pm screen shot 2016-09-19 at 12 00 04 am

    opened by otymartin 21
  • How to use the dialog with a custom view controller?

    How to use the dialog with a custom view controller?

    Please fill out this template when filing an issue. All ℹ symbols should be replaced with information on the issue. Please remove this line and all above before submitting.

    Report

    Environment

    Please provide information on your development environment, so we can build with the same scenario.

    • Mac OS version (e.g. 10.12): ℹ10.12.2
    • Xcode version (e.g. 8.0): ℹ8.0
    • PopupDialog version (e.g. 0.5.0): ℹ0.5.0
    • Minimum deployment target (e.g. 9.0): ℹ9.0
    • Language (Objective-C / Swift): ℹSwift
    • In case of Swift - Version (e.g. 3.0): ℹ3.0

    Dependency management

    If you are not using any dependency managers, you can remove this section.

    Please note: If you are using CocoaPods with Xcode 8, CocoaPods 1.1.0 is required.

    • Dependency manager (e.g. CocoaPods): ℹCocoaPods
    • Version (e.g. 1.1.0): ℹ 1.1.0

    Hi I was wondering if it is possible to pass information to the PopupViewController which can then be used in labels. I have three buttons in a view controller that all launch the same PopupViewController, but I want them to display different information in the labels etc. based on what button was selected, but I cannot seem to find a way to do this! e.g. if button 1 is selected, the label displays 'Button 1 was selected', if button 2 was selected then the label displays 'Button 2 was selected' etc.

    question 
    opened by RyanHop3 18
  • Possible to add alignment on button styles?

    Possible to add alignment on button styles?

    Report

    Environment

    Please provide information on your development environment, so we can build with the same scenario.

    • Xcode version (e.g. 9.1): 8.3.2
    • PopupDialog version (e.g. 0.5.0): 0.6
    • Minimum deployment target (e.g. 9.0): 9.0
    • Language (Objective-C / Swift): Swift
    • In case of Swift - Version (e.g. 4): 4

    Dependency management

    If you are not using any dependency managers, you can remove this section.

    • Dependency manager (e.g. CocoaPods): CocoaPods
    • Version (e.g. 1.3.1): ℹ

    What did you do?

    I tried fiddling with button.contentHorizontalAlignment and button.contentEdgeInserts in order to make the buttons right aligned, similar to how Google Material aligns "flat buttons" in Material alerts and dialogues:

    screen shot 2017-12-05 at 7 53 52 pm

    What did you expect to happen?

    Buttons to align to the right of the view

    What happened instead?

    Buttons are always centered and take over the full width of the view, presumably because there is some auto-layout config going on.

    Thoughts? Love this library for its ease of use, and ability to add images, but would be really nice if it was just a little more flexible in this way.

    wontfix 
    opened by jhochenbaum 13
  • Popup dialog doesn't appear when app is in background

    Popup dialog doesn't appear when app is in background

    Please fill out this template when filing an issue. All ℹ symbols should be replaced with information on the issue. Please remove this line and all above before submitting.

    Thanks for this library. It's pretty useful. Here is the bug I am facing:

    Report

    Environment

    Please provide information on your development environment, so we can build with the same scenario.

    • Mac OS version (e.g. 10.12): 10.11.6
    • Xcode version (e.g. 8.0): 8.2.1
    • PopupDialog version (e.g. 0.5.0): 0.5.4
    • Minimum deployment target (e.g. 9.0): 9.0
    • Language (Objective-C / Swift): Swift
    • In case of Swift - Version (e.g. 3.0): 3.0

    Dependency management

    If you are not using any dependency managers, you can remove this section.

    Please note: If you are using CocoaPods with Xcode 8, CocoaPods 1.1.0 is required.

    • Dependency manager (e.g. CocoaPods): Cocapods
    • Version (e.g. 1.1.0): 1.2.0

    What did you do?

    Present a popup dialog when app is in background. This was first observed when a network call finished when app was in background. Second time to simulate it, a timer was used to fire when app was in background.

    What did you expect to happen?

    When app comes back to foreground (appWillEnterForeground:), popup dialog should be present on the screen.

    What happened instead?

    Popup Dialog was not present on the screen.

    Project that demonstrates the issue

    Let me know if this is needed, I will upload one.

    ℹ In complex cases, it might be useful to link to a sample project. If you don't provide an example, you can delete this section.

    ready for testing Included in next release 
    opened by kabiryeshe 13
  • Main Thread Checker throws Error in Xcode 9.2

    Main Thread Checker throws Error in Xcode 9.2

    • Xcode version (e.g. 9.1): 9.2
    • PopupDialog version (e.g. 0.5.0): latest
    • Minimum deployment target (e.g. 9.0): 10.0
    • Language (Objective-C / Swift): Swift
    • In case of Swift - Version (e.g. 4): 4
    • Dependency manager (e.g. CocoaPods): yes
    • Version (e.g. 1.3.1): yes

    When presenting the popup, the first time it is presented after pressing a button, I get the following logs in the console: First: Warning: Attempt to present ... viewController.... whose view is not in the window hierarchy!

    Then:

    Main Thread Checker: UI API called on a background thread: -[UIView layer]
    PID: 10924, TID: 3479577, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 21
    Backtrace:
    

    This issue persists even when wrapping everything in DispatchQueue.main.async { .. }.

    After doing some research, seems like you may have some updating to do as mentioned here: https://stackoverflow.com/a/44392584/5912335

    Or is there another solution?

    ready for testing Included in next release 
    opened by Ruckt 12
  • Custom PopupDialog click events and TextField not working

    Custom PopupDialog click events and TextField not working

    simulator screen shot 18-sep-2017 7 55 35 pm

    I have created a custom PopupDialog as above in screenshot but the button click events for Ok and Cancel are not working as well as TextField (comment) and Stepper are also not working.

    Please help me out what wrong I am doing.

    opened by krishnameena 12
  • Random crash on PopupDialog , not reproducible easily.

    Random crash on PopupDialog , not reproducible easily.

    Report

    Environment

    • Mac OS version (e.g. 10.12.5): 10.12.5
    • Xcode version (e.g. 8.0): 8.3
    • PopupDialog version (e.g. 0.5.0): 0.5
    • Minimum deployment target (e.g. 9.0): 8.0
    • Language (Objective-C / Swift): swift
    • In case of Swift - Version (e.g. 3.0): 3

    Dependency management

    Please note: If you are using CocoaPods with Xcode 8, CocoaPods 1.1.0 is required.

    • Dependency manager (e.g. CocoaPods): CocoaPods
    • Version (e.g. 1.1.0): 1.2.0

    What did you do?

    Crash while using the app.

    What did you expect to happen?

    Do not crash

    What happened instead?

    App crashed while testing.

    Crash reported on the crashlytics log are attached below.

    crash

    bug help wanted wontfix 
    opened by shrawan2015 12
  • using slider

    using slider "WARangeSlider" in dialog

    Report

    using slider "WARangeSlider" in dialog swipe not working

    Environment

    Please provide information on your development environment, so we can build with the same scenario.

    • Mac OS version 10.12
    • Xcode version 8.0
    • PopupDialog version 0.5.4
    • Minimum deployment target 9.0
    • Language (Swift)
    • In case of Swift 3.1

    Dependency management

    If you are not using any dependency managers, you can remove this section.

    Please note: If you are using CocoaPods with Xcode 8, CocoaPods 1.1.0 is required.

    • Dependency manager CocoaPods
    • Version (1.1.0)

    untitled-1 .

    awaiting-feedback 
    opened by ahmedAlmasri 12
  • Crash when presenting PopupDialog DynmicBlurView

    Crash when presenting PopupDialog DynmicBlurView

    Report

    Exception Type: SIGSEGV Exception Codes: SEGV_ACCERR at 0x16904ee488 Crashed Thread: 0

    Thread 0 Crashed: 0 CoreGraphics 0x00000001ed830ddc CGColorGetAlpha + 12 1 QuartzCore 0x00000001f0086bf4 -[CALayer _renderBorderInContext:] + 144 2 QuartzCore 0x00000001f0088b5c -[CALayer renderInContext:] + 1396 3 QuartzCore 0x00000001f0086ea4 -[CALayer _renderSublayersInContext:] + 368 4 QuartzCore 0x00000001f0088b48 -[CALayer renderInContext:] + 1376 5 QuartzCore 0x00000001f0086ea4 -[CALayer _renderSublayersInContext:] + 368 6 QuartzCore 0x00000001f0088b48 -[CALayer renderInContext:] + 1376 7 QuartzCore 0x00000001f0086ea4 -[CALayer _renderSublayersInContext:] + 368 8 QuartzCore 0x00000001f0088b48 -[CALayer renderInContext:] + 1376 9 QuartzCore 0x00000001f0086ea4 -[CALayer _renderSublayersInContext:] + 368 10 QuartzCore 0x00000001f0088b48 -[CALayer renderInContext:] + 1376 11 QuartzCore 0x00000001f0086ea4 -[CALayer _renderSublayersInContext:] + 368 12 QuartzCore 0x00000001f0088b48 -[CALayer renderInContext:] + 1376 13 QuartzCore 0x00000001f0086ea4 -[CALayer _renderSublayersInContext:] + 368 14 QuartzCore 0x00000001f0088b48 -[CALayer renderInContext:] + 1376 15 QuartzCore 0x00000001f0086ea4 -[CALayer _renderSublayersInContext:] + 368 16 QuartzCore 0x00000001f0088b48 -[CALayer renderInContext:] + 1376 17 QuartzCore 0x00000001f0086ea4 -[CALayer _renderSublayersInContext:] + 368 18 QuartzCore 0x00000001f0088b48 -[CALayer renderInContext:] + 1376 19 QuartzCore 0x00000001f0086ea4 -[CALayer _renderSublayersInContext:] + 368 20 QuartzCore 0x00000001f0088b48 -[CALayer renderInContext:] + 1376 21 QuartzCore 0x00000001f0086ea4 -[CALayer _renderSublayersInContext:] + 368 22 QuartzCore 0x00000001f0088b48 -[CALayer renderInContext:] + 1376 23 DynamicBlurView 0x00000001060da560 DynamicBlurView.BlurLayer.render(in: __C.CGContextRef, for: __C.CALayer) -> () (BlurLayer.swift:94) 24 DynamicBlurView 0x00000001060df684 DynamicBlurView.DynamicBlurView.(snapshotImage in _2044C6510BFEB36C5566C936E3D26E26)(for: __C.CALayer, conversion: Swift.Bool) -> __C.UIImage? (DynamicBlurView.swift:142) 25 DynamicBlurView 0x00000001060dffd8 function signature specialization <Arg[0] = Dead> of DynamicBlurView.DynamicBlurView.display(__C.CALayer) -> () (DynamicBlurView.swift:156) 26 DynamicBlurView 0x00000001060df7b4 @objc DynamicBlurView.DynamicBlurView.display(__C.CALayer) -> () (:0) 27 DynamicBlurView 0x00000001060df934 DynamicBlurView.DynamicBlurView.refresh() -> () (DynamicBlurView.swift:180) 28 PopupDialog 0x000000010ae77240 PopupDialog.PresentationController.containerViewWillLayoutSubviews() -> () (PresentationController.swift:58) 29 PopupDialog 0x000000010ae77288 merged @objc PopupDialog.PresentationController.presentationTransitionWillBegin() -> () + 24 30 UIKitCore 0x0000000219386fe4 -[UIView(CALayerDelegate) layoutSublayersOfLayer:] + 1116 31 libobjc.A.dylib 0x00000001eacab454 -[NSObject performSelector:withObject:] + 64 32 QuartzCore 0x00000001f0083db4 -[CALayer layoutSublayers] + 184 33 QuartzCore 0x00000001f00840a0 CA::Layer::layout_if_needed(CA::Transaction*) + 332 34 QuartzCore 0x00000001f0083f1c -[CALayer layoutIfNeeded] + 228 35 QuartzCore 0x00000001f0088690 -[CALayer renderInContext:] + 168 36 DynamicBlurView 0x00000001060da560 DynamicBlurView.BlurLayer.render(in: __C.CGContextRef, for: __C.CALayer) -> () (BlurLayer.swift:94) 37 DynamicBlurView 0x00000001060df684 DynamicBlurView.DynamicBlurView.(snapshotImage in _2044C6510BFEB36C5566C936E3D26E26)(for: __C.CALayer, conversion: Swift.Bool) -> __C.UIImage? (DynamicBlurView.swift:142) 38 DynamicBlurView 0x00000001060de828 DynamicBlurView.DynamicBlurView.didMoveToWindow() -> () (DynamicBlurView.swift:86) 39 DynamicBlurView 0x00000001060de944 merged @objc DynamicBlurView.DynamicBlurView.didMoveToWindow() -> () + 24 40 UIKitCore 0x000000021937e288 -[UIView(Internal) _didMoveFromWindow:toWindow:] + 1604 41 UIKitCore 0x000000021937dedc -[UIView(Internal) _didMoveFromWindow:toWindow:] + 664 42 UIKitCore 0x00000002193712ac __45-[UIView(Hierarchy) _postMovedFromSuperview:]_block_invoke + 156 43 Foundation 0x00000001ec437634 -[NSISEngine withBehaviors:performModifications:] + 112 44 UIKitCore 0x000000021937118c -[UIView(Hierarchy) _postMovedFromSuperview:] + 816 45 UIKitCore 0x0000000219380d20 -[UIView(Internal) _addSubview:positioned:relativeTo:] + 1740 46 PopupDialog 0x000000010ae76d74 PopupDialog.PresentationController.presentationTransitionWillBegin() -> () (PresentationController.swift:40) 47 PopupDialog 0x000000010ae77288 merged @objc PopupDialog.PresentationController.presentationTransitionWillBegin() -> () + 24 48 UIKitCore 0x000000021882dc8c __71-[UIPresentationController _initViewHierarchyForPresentationSuperview:]_block_invoke + 2224 49 UIKitCore 0x000000021882b6e0 __56-[UIPresentationController runTransitionForCurrentState]_block_invoke + 468 50 UIKitCore 0x000000021890fa64 __40+[UIViewController _scheduleTransition:]_block_invoke + 24 51 UIKitCore 0x0000000218edd1fc _runAfterCACommitDeferredBlocks + 300 52 UIKitCore 0x0000000218ecb3bc _cleanUpAfterCAFlushAndRunDeferredBlocks + 352 53 UIKitCore 0x0000000218ef9a3c _afterCACommitHandler + 116 54 CoreFoundation 0x00000001eba3a0e8 CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION + 32 55 CoreFoundation 0x00000001eba34be0 __CFRunLoopDoObservers + 412 56 CoreFoundation 0x00000001eba35140 __CFRunLoopRun + 1208 57 CoreFoundation 0x00000001eba34964 CFRunLoopRunSpecific + 448 58 GraphicsServices 0x00000001edc75d8c GSEventRunModal + 104 59 UIKitCore 0x0000000218ed1758 UIApplicationMain + 212 60 VW-R-CLUB Member APP 0x000000010292ffdc main (AppDelegate.swift:20) 61 libdyld.dylib 0x00000001eb4f0fd8 start + 0

    crash report:

    func render(in context: CGContext, for layer: CALayer) {
    let layers = hideOverlappingLayers(layer.sublayers)
    layer.render(in: context)    <------------------------------ here
    layers.forEach {
        $0.isHidden = false
    }
    

    }

    private func snapshotImage(for layer: CALayer, conversion: Bool) -> UIImage? {
    let rect = blurLayerRect(to: layer, conversion: conversion)
    guard let context = CGContext.imageContext(with: quality, rect: rect, opaque: isOpaque) else {
        return nil
    }
    
    blurLayer.render(in: context, for: layer)  <------------------------------ here
    
    defer {
        UIGraphicsEndImageContext()
    }
    
    return UIGraphicsGetImageFromCurrentImageContext()
    

    }

    extension DynamicBlurView {
    open override func display(_ layer: CALayer) {
    let blurRadius = blurLayer.presentationRadius
    let isFixes = isDeepRendering && staticImage != nil
    if let view = renderingTarget, let image = staticImage ?? snapshotImage(for: view.layer, conversion: !isFixes) {   <------------------------------ here <Arg[0] = Dead> of DynamicBlurView.DynamicBlurView.display(__C.CALayer) -> () (DynamicBlurView.swift:156)
        draw(image, blurRadius: blurRadius, fixes: isFixes, baseLayer: view.layer)
    }
    

    } }

    extension DynamicBlurView {
    /// Remove cache of blur image then get it again.
     open func refresh() {
    blurLayer.refresh()
    staticImage = nil
    blurRatio = 1
    display(layer) <------------------------------ here
    

    } Hope you can help me to fix it.

    The crash only happens sometimes.

    Environment

    Please provide information on your development environment, so we can build with the same scenario.

    • Xcode version (e.g. 9.1):10.3
    • PopupDialog version (e.g. 0.5.0): Current (1.1.0)
    • Minimum deployment target (e.g. 9.0): 9.0
    • Language (Objective-C / Swift): SWIFT
    • In case of Swift - Version (e.g. 4):5

    Dependency management

    Cocapod 1.7.2

    What did you do?

    just show a popup

    What did you expect to happen?

    popup show up

    What happened instead?

    app crashed (only sometimes)

    wontfix investigating 
    opened by Skyb0rg 11
  • Attempt to present <PopupDialog.PopupDialog: 0x7fef6f416760> on <PopupDialog.PopupDialog: 0x7fef6f502c60> whose view is not in the window hierarchy!

    Attempt to present on whose view is not in the window hierarchy!

    I can't present second VC on the completion handler of firstVC dismiss.

    Why is that ?

    mainVC.swift

    import UIKit
    import PopupDialog
    
    class mainVC: UIViewController {
    
        override func viewDidLoad() {
            super.viewDidLoad()
    
            
        }
    
        @IBAction func startButtonPressed(_ sender: Any) {
            
            // Create a custom view controller
            let vc = firstVC(nibName: "firstVC", bundle: nil)
            
            // Create the dialog
            let popup = PopupDialog(viewController: vc, buttonAlignment: .horizontal, transitionStyle: .bounceDown, gestureDismissal: true)
           
            vc.popup = popup
            
            // Present dialog
            present(popup, animated: true, completion: nil)
            
        }
        
    }
    

    firstVC.swift

    
    
    import UIKit
    import PopupDialog
    
    class firstVC: UIViewController {
    
        public weak var popup: PopupDialog?
        
        override func viewDidLoad() {
            super.viewDidLoad()
    
            
        }
    
        @IBAction func closeButtonPressed(_ sender: Any) {
            popup?.dismiss()
        }
        
        @IBAction func open2ndVC(_ sender: Any) {
            popup?.dismiss({
                
                let vc2 = secondVC(nibName: "secondVC", bundle: nil)
                let popup2 = PopupDialog(viewController: vc2, buttonAlignment: .horizontal, transitionStyle: .bounceDown, gestureDismissal: true)
                vc2.popupFor2ndVC = popup2
                self.popup?.present(popup2, animated: true, completion: nil)
            })
        }
        }
    

    secondVC.swift

    import UIKit
    import PopupDialog
    
    class secondVC: UIViewController {
        public weak var popupFor2ndVC: PopupDialog?
        
        override func viewDidLoad() {
            super.viewDidLoad()
                print("SecondVC loaded")
        }
    }
    
    opened by herotheone 11
  • Example can't run successfully  after cocoapod install.

    Example can't run successfully after cocoapod install.

    Please fill out this template when filing an issue. All ℹ symbols should be replaced with information on the issue. Please remove this line and all above before submitting.

    Report

    Environment

    Please provide information on your development environment, so we can build with the same scenario.

    • Xcode version (e.g. 9.1): ℹ 13.4
    • PopupDialog version (e.g. 0.5.0): ℹ 1.1.1
    • Minimum deployment target (e.g. 9.0): ℹ 12
    • Language (Objective-C / Swift): ℹSwift
    • In case of Swift - Version (e.g. 4): ℹ swift 5.5

    Dependency management

    If you are not using any dependency managers, you can remove this section.

    • Dependency manager (e.g. CocoaPods): ℹ
    • Version (e.g. 1.3.1): ℹ 1.11.3

    What did you do?

    cocoapod install

    run Example then "ld: library not found for -lswiftXCTest clang: error: linker command failed with exit code 1 (use -v to see invocation)"

    opened by jiexishede 0
  • Can't integrate library via SPM if no tag is added.

    Can't integrate library via SPM if no tag is added.

    In order to be able to integrate PopupDialog via SPM a release must be created with a tag. Last tag pushed was October/2019 and aparently SPM was added in 2021.

    opened by cotchoninha 0
  • Changing blurEnabled and opacity for a single instance of PopupDialog

    Changing blurEnabled and opacity for a single instance of PopupDialog

    I have a need to change PopupDialogOverlayView.blurEnabled and .opacity for a single instance of PopupDialog, and not for others. While I can change PopupDialogOverlayView.appearance() before and after I use the dialog, that is a bit hacky and I would like to figure out the cleanest way to change these parameters for a single instance.

    If this is not possible now then I would like to have this feature added if possible.

    opened by jeffduet 0
  • Crashes when initializing popup from background thread

    Crashes when initializing popup from background thread

    • Xcode version 12.5.1: ℹ

    • PopupDialog version 1.1.1: ℹ

    • Minimum deployment target 13.4: ℹ

    • Language Swift: ℹ

    • Swift - Version 5.0: ℹ

    • Dependency manager CocoaPods: ℹ

    • Version 1.10.1: ℹ

    I am trying to present DopupDialog from background thread:

    let popup = PopupDialog(title: title, message: message, buttonAlignment: .horizontal, transitionStyle: .zoomIn, tapGestureDismissal: true, panGestureDismissal: true, hideStatusBar: false) {}

    I am getting error: Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'Modifications to the layout engine must not be performed from a background thread after it has been accessed from the main thread.'

    Error happening on the line 57:

    Screen Shot 2021-09-01 at 5 58 44 PM
    opened by aebanoidze 0
  • Changing DefaultButton appearance while typing

    Changing DefaultButton appearance while typing

    Hi,

    Thanks for your useful repo.

    • Xcode version (12.5.1)

    • PopupDialog version (1.1.1)

    • Minimum deployment target (14.0)

    • Language (Swift)

    • In case of Swift - Version (5)

    • Dependency manager (CocoaPods)

    • Version (1.10.0)

    I have a custom PopupDialog, I changed the appearance of the DefaultButton using the following lines of code:

    let db = DefaultButton.appearance()
         db.titleFont   = .optionsFont
         db.titleColor  = UIColor.optionsColor
         db.buttonColor = UIColor.buttonColor
    

    I need to set different colors appearance when the text field is empty. Then, when user starts typing I need to change the colors.

    Could you please guide me how to do it?

    opened by Maryom 0
  • Error: Typedef 'UILayoutConstraintAxis' cannot be referenced with a enum specifier

    Error: Typedef 'UILayoutConstraintAxis' cannot be referenced with a enum specifier

    Report

    I am using this library in my App, I have multiple targets, getting following error while building one of my targets, others are fine.

    Typedef 'UILayoutConstraintAxis' cannot be referenced with a enum specifier

    Environment

    Please provide information on your development environment, so we can build with the same scenario.

    • Xcode version (12.4 (12D4e)): ℹ
    • PopupDialog version (1.1): ℹ
    • Minimum deployment target (10.0): ℹ
    • Language (Objective-C): ℹ

    Dependency management

    If you are not using any dependency managers, you can remove this section.

    • Dependency manager (CocoaPods): ℹ
    • Version (1.10.1): ℹ

    What did you do?

    While I am building one of my target I am getting following error if enum UILayoutConstraintAxis in library,

    /Users/**/Library/Developer/Xcode/DerivedData/****/Build/Products/Debug-iphonesimulator/PopupDialog/PopupDialog.framework/Headers/PopupDialog-Swift.h:266:160: Typedef 'UILayoutConstraintAxis' cannot be referenced with a enum specifier

    What did you expect to happen?

    As I am using two target, one is building fine while other is giving this error, expect to build successful as other target.

    What happened instead?

    Instead I am getting error of enum UILayoutConstraintAxis

    /Users/**/Library/Developer/Xcode/DerivedData/****/Build/Products/Debug-iphonesimulator/PopupDialog/PopupDialog.framework/Headers/PopupDialog-Swift.h:266:160: Typedef 'UILayoutConstraintAxis' cannot be referenced with a enum specifier

    opened by DineshKachhot 0
Releases(1.1.1)
Owner
Orderella Ltd.
Orderella Ltd.
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
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
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
A fully customizable popup style menu for iOS 😎

Guide Check out the documentation and guides for details on how to use. (Available languages:) English 简体中文 What's a better way to know what PopMenu o

Cali Castle 1.5k Dec 30, 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
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
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
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
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 tiny extension for UIAlertController that makes working with it very simple. Only 150 lines of code.

AlertController ?? A tiny extension for UIAlertController that makes working with it very simple. Only 150 lines of code. Alert let alert = UIAlertCon

Mezhevikin Alexey 9 Nov 2, 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
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

Sahil 2k Dec 22, 2022
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

Viktor Radchenko 5.2k Jan 3, 2023
Beautiful animated Login Alert View. Written in Objective-C

UIAlertView - Objective-C Animated Login Alert View written in Swift but ported to Objective-C, which can be used as a UIAlertView or UIAlertControlle

Letovsky 2 Dec 22, 2021
Animated Alert written in SwiftUI.

TransactionAlert Animated Alert written in SwiftUI. Easy to use Get Started Add a TAViewModel instance as an environment object to your Root View in y

null 11 Jul 21, 2022
Simple DropDown Alert View For Any iOS Projects.

⚠️ DEPRECATED, NO LONGER MAINTAINED JDropDownAlert JDropDownALert Simple DropDown Alert View For Any iOS Projects. Usage Top let alert = JDropDown

WonJo 71 Jul 17, 2022