DYModalNavigationController 1.2.1

DYModalNavigationController 1.2.1

Maintained by Dominik Butz.

  • By
  • dominikbutz


Version License Platform Carthage compatible

DYModalNavigationController is a simple UINavigationController subclass written in Swift 5.0. Use cases:

  • present a small size view controller with rounded edges over the current context modally (e.g. if the content is rather small and the standard modal presentation would show a lot of empty space). Set a fixed size so that the navigation controller's size is not adjusted when the screen orientation changes.
  • present a modal view controller over the current context with top, bottom, left, right margins with a fade in transition. The presenting view controller behind it is still visible at the margins (unless margins set to 0). The size adjusts automatically when the screen orientation changes.
  • works in a SwiftUI project even without using UIViewControllerRepresentable. Simply create an instance of the DYModalNavigationController and call present() on the instance (available from version 1.2.1)

Example project

To checkout the example project, simply clone the repo or download the zip file.


  • Create a DYModalNavigationController with a fixed size in case your view controller instance should not change its size when changing the screen orientation.
  • Set a background blur or dim effect
  • Customise the corner radius of the DYModalNavigationController view.
  • Set a slide in/out animation (customisable animation movement directions) or a fade in/out animation
  • Customise the drop shadow
  • Customise the animation transition duration


Installation through Cocoapods or Carthage is recommended.


target '[project name]' do pod 'DYModalNavigationController' end

Carthage: Simply add the following line to your Cartfile.

github "DominikButz/DYModalNavigationController" ~> 1.0

Check out the version history below for the current version.

Afterwards, run "carthage update DYModalNavigationController --platform iOS" in the root directory of your project. Follow the steps described in the carthage project on github (click on the carthage compatible shield above).

Make sure to import DYModalNavigationController into your View Controller subclass:

import DYModalNavigationController


Check out the following examples.

Code example: Fixed size DYModalNavigationController with background blur

   let size = CGSize(width: 300, height: 200)
   var settings = DYModalNavigationControllerSettings()
	   settings.slideInDirection = .right
   settings.slideOutDirection = .right
   settings.backgroundEffect = .blur
   self.navController = DYModalNavigationController(rootViewController: 			contentVC(), fixedSize: size, settings: settings)

DYModalNavigationController example

Code example: DYModalNavigationController with margins and fade effect

   var settings = DYModalNavigationControllerSettings()
		settings.animationType  = .fadeInOut
		// animationType .slideInOut is default setting!
   self.navController = DYModalNavigationController(rootViewController: 			contentVC(), fixedSize: nil, settings: settings)
   // with fixedSize nil, the size will be set according to the top, bottom, 			left, right margins in the settings. 

DYModalNavigationController example

Code example: DYModalNavigationController with custom animations

   var settings = DYModalNavigationControllerSettings()
		settings.animationType = .custom
   self.navController = DYModalNavigationController(rootViewController: 			contentVC(), fixedSize: size, settings: settings, customPresentationAnimation: { (transitionContext) in
   self.foldOut(transitionContext: transitionContext, navController: self.navController)
       }, customDismissalAnimation: { (transitionContext) in
    self.foldIn(transitionContext: transitionContext, navController: self.navController)

DYModalNavigationController example

Change log

Version 1.2.1

Added customMask as property in DYModalNavigationControllerSettings (allows rounding a subset of corners). Added extension for SwiftUI with present function.

Version 1.2

added backgroundEffectView as accessible parameter in the customAnimation closures.

Version 1.1

added customPresentationAnimation and customDismissalAnimation to the initializer.

Version 1.0

initial version.


[email protected]


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