Swiftpack.co - danielhorv/Modamic as Swift Package

Swiftpack.co is a collection of thousands of indexed Swift packages. Search packages.
See all packages published by danielhorv.
danielhorv/Modamic v0.0.2
Lightweight library for presenting UIViewController in Modal.
⭐️ 6
🕓 2 weeks ago
.package(url: "https://github.com/danielhorv/Modamic.git", from: "v0.0.2")


Lightweight library for presenting UIViewController in Modal.

⚠️ the library is WIP, if you find a bug, please create an issue or pull request


Preview Preview Preview

Features 🎉

  • automatic keyboard handling
  • runtime animated resizing
  • customizable configuration
  • vertical positions
  • custom AnimatedTransitioning
  • UINavigationController support
  • coordination pattern support


Available vertical positions

  • top
  • center
  • bottom


There is a default ModemicConfiguration, but you can also create a custom configuration. The list of the available properties

    /// The presented controller have rounded corners.
    public var roundCorners: Bool = true
    /// Radius of rounded corners for presented controller if roundCorners is true.
    public var cornerRadius: CGFloat = 10
    /// Keyboard shows animation duration
    public var showKeyboardAnimationDuration: TimeInterval = 0.5
    /// Keyboard hiding animation duration
    public var hideKeyboardAnimationDuration: TimeInterval = 0.5
    /// Non notch device bottom spacing
    public var nonNotchBottomSpacing: CGFloat = 20
    /// Non notch device top spacing
    public var nonNotchTopSpacing: CGFloat = 20
    /// Automatically dismisses keyboard if the viewController is dismissed
    public var autoDismissKeyboard: Bool = true
    /// Background color of the dimmed backgroundView
    public var dimmingViewBackgroundColor = UIColor(white: 0, alpha: 0.4)
    /// Cutomize the animation of the contentSize resizing
    public var contentSizeChangedAnimationOptions: AnimationSettings = (duration: 0.3, delay: 0, usingSpringWithDamping: 0.8, initialSpringVelocity: 15)

    /// Tap on the backgroundView automatically dismisses the ViewController
    public var autoDismissOnBackgroundTap: Bool = true
    /// Vertical position of the viewController
    public var modalVerticalPosition: ModalVerticalPosition = .bottom
    /// Width of the modal viewController
    public var modalWidth: ModalWidth = .parentFactor(0.9)
    /// Animated transition for the modal
    public var animatedTransition: AnimatedTransition = .bottom

Runtime resizing

The library supports AutoLayout, so if you add/remove some view or change the height of a subview, you just need to call the setPreferredContentSizeFromAutolayout() method of the UIViewController. This will recalculate the height and animate the resized modal - check the example project.


There are 2 ways to define the width of the modal

  • dynamic: use a factor to scale the width of the parent ViewController
  • fixed: set a fixed width for the modal

Animation Transition

You can use the default (bottom push) and also a top animation to present your modal. But there is also a custom(forPresented: UIViewControllerAnimatedTransitioning, forDismissed: UIViewControllerAnimatedTransitioning) case to use your custom Animation.


    let modamicConfig = ModamicConfiguration()
    modamicConfig.autoDismissKeyboard = false
    modamicConfig.modalVerticalPosition = .center

    let presenter = ModamicPresenter(configuration: modamicConfig)
    presenter.presentModal(viewController: updateViewController, on: self, completion: nil)


  • scrollView if the content is bigger than the screen
  • rotation handling



pod "Modamic"

Swift Package Manager:



  • Swift 5
  • iOS 9


Stars: 6
Last commit: 2 weeks ago
jonrohan Something's broken? Yell at me @ptrpavlik. Praise and feedback (and money) is also welcome.

Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics