Skip to content

daihase/LSDialogViewController

Repository files navigation

Language: Swift 5.0 License Platform Swift Package Manager CocoaPodsDL Carthage Compatible

LSDialogViewController makes it easy to display a custom view as a dialog with various animation patterns.

LSDialogViewController_animation

Requirements

  • Swift 5.0+
  • iOS 12.0+

Installation

Swift Package Manager (Recommended)

Add the following to your Package.swift:

dependencies: [
    .package(url: "https://github.com/daihase/LSDialogViewController.git", from: "4.1")
]

Or in Xcode: File → Add Package Dependencies... → Enter the repository URL:

https://github.com/daihase/LSDialogViewController.git

CocoaPods

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

pod 'LSDialogViewController', '~> 4.0'

Carthage

Add the following to your Cartfile:

github "daihase/LSDialogViewController"

Then run:

$ carthage update

Usage

To run the example project, clone the repo and run pod install from the Example directory. There is also an SPM-based example in the ExampleSPM directory — just open ExampleSPM.xcodeproj and build.

Examples

import LSDialogViewController

// Show a dialog
let dialogViewController = CustomDialogViewController(nibName: "CustomDialog", bundle: nil)
dialogViewController.delegate = self
presentDialogViewController(dialogViewController, animationPattern: .fadeInOut)

// Dismiss the dialog
dismissDialogViewController(.fadeInOut)

Configuration

presentDialogViewController(
    // Required: the view controller to display as a dialog
    dialogViewController: UIViewController,
    // Animation pattern (default: .fadeInOut)
    animationPattern: LSAnimationPattern,
    // Background view type (default: .solid)
    backgroundViewType: LSDialogBackgroundViewType,
    // Whether tapping the background dismisses the dialog (default: true)
    dismissButtonEnabled: Bool,
    // Called after the dialog is presented
    completion: (() -> Swift.Void)?
)

Background View Types

You can choose from .solid, .gradient, or .none:

Image . Image

License

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

About

Custom Dialog for iOS written in Swift

Topics

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors