Lightweight library for presenting UIViewController in Modal.
⚠️ the library is WIP, if you find a bug, please create an issue or pull request
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
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
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)
Swift Package Manager: