Latest 5.0.3
License MIT
Platforms ios 9.3



🌲 Bonsai makes iOS View Controller present modally in any size and any position with cool transition animation.



  • [x] Makes view controller appear as
    • [x] Popup alert (no dismiss on tap outside)
    • [x] Notification alert (auto dismiss after delay)
    • [x] Side menu (drawer)
  • [x] Transition animation
    • [x] Slide In from left, right, top and bottom
    • [x] Bubble pop from an initial frame or a view
  • [x] Blur effect on background
    • [x] light, dark, regular, prominent
  • [x] Supports Storyboard and Code
  • [x] Supports landscape and portrait orientation
  • [x] Created with Swift compatible with Objective-C
  • [x] Preserves Safe Area and Auto Layout constraints

Installation with CocoaPods

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

pod 'BonsaiController'

Install Manually

Drag the ~/BonsaiController directory anywhere in your project.

How to use

import BonsaiController

Add (copy paste) BonsaiControllerDelegate extension to your view controller

extension YourViewController: BonsaiControllerDelegate {

    // return the frame of your Bonsai View Controller
    func frameOfPresentedView(in containerViewFrame: CGRect) -> CGRect {

        return CGRect(origin: CGPoint(x: 0, y: containerViewFrame.height / 4), size: CGSize(width: containerViewFrame.width, height: containerViewFrame.height / (4/3)))

    // return a Bonsai Controller with SlideIn or Bubble transition animator
    func presentationController(forPresented presented: UIViewController, presenting: UIViewController?, source: UIViewController) -> UIPresentationController? {

        // Slide animation from .left, .right, .top, .bottom
        return BonsaiController(fromDirection: .bottom, blurEffectStyle: .light, presentedViewController: presented, delegate: self)

        // or Bubble animation initiated from a view
        //return BonsaiController(fromView: yourOriginView, blurEffectStyle: .dark,  presentedViewController: presented, delegate: self)

How to present the view controller

From Code:

let smallVC = YourViewController() // instantiateViewController(withIdentifier:)
smallVC.transitioningDelegate = self
smallVC.modalPresentationStyle = .custom
present(smallVC, animated: true, completion: nil)

From Storyboard:

override func prepare(for segue: UIStoryboardSegue, sender: Any?) {

    if segue.destination is YourViewController {
        segue.destination.transitioningDelegate = self
        segue.destination.modalPresentationStyle = .custom


Auto dismiss after delay

let bonsaiController = BonsaiController(...
bonsaiController.perform(#selector(bonsaiController.dismiss), with: nil, afterDelay: 2)

Customizable properties (Default values)

bonsaiController.springWithDamping = 0.8
bonsaiController.duration = 0.4
bonsaiController.isDisabledTapOutside = false
bonsaiController.isDisabledDismissAnimation = false
bonsaiController.dismissDirection = nil // Reverse direction. Availabel only for slide in transition.

Custom transition animation

If you want to create your own transition animation, implement this protocol in your viewController

extension YourViewController: UIViewControllerTransitioningDelegate {

    func animationController(forPresented presented: UIViewController, presenting: UIViewController, source: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        // Your presentation animation hear

    func animationController(forDismissed dismissed: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        // Your dismiss animation here

Usage In Objective-C

#import "YourModuleName-Swift.h"  // only if project created in swift

@import BonsaiController;

Add (copy paste) BonsaiControllerDelegate extension to your view controller

// MARK:- Bonsai Controller Delegate
- (CGRect)frameOfPresentedViewIn:(CGRect)containerViewFrame {

    return CGRectMake(0, containerViewFrame.size.height / 4, containerViewFrame.size.width, containerViewFrame.size.height / (4.0 / 3.0));

- (UIPresentationController *)presentationControllerForPresentedViewController:(UIViewController *)presented presentingViewController:(UIViewController *)presenting sourceViewController:(UIViewController *)source {

    // Slide animation from .left, .right, .top, .bottom
    //return [[BonsaiController alloc] initFromDirection:DirectionBottom blurEffectStyle:UIBlurEffectStyleLight presentedViewController:presented delegate:self];

    // or Bubble animation initiated from a view
    return [[BonsaiController alloc] initFromView:self.exampleButton blurEffectStyle:UIBlurEffectStyleDark presentedViewController:presented delegate:self];

How to present the view controller(obj-c)

From Code:

SmallViewController *smallVC = [self.storyboard instantiateViewControllerWithIdentifier:@"SmallVC"];
smallVC.transitioningDelegate = self;
smallVC.modalPresentationStyle = UIModalPresentationCustom;
[self presentViewController:smallVC animated:true completion:nil];

From Storyboard:

- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {

    if ([segue.destinationViewController isKindOfClass:SmallViewController.class]) {
        segue.destinationViewController.transitioningDelegate = self;
        segue.destinationViewController.modalPresentationStyle = UIModalPresentationCustom;


An example project is included with this repo. To run the example project, clone the repo, and run pod install from the Example directory first.

Minimum Requirements

  • Xcode 10.2 with swift5 (check previous releases and pod versions for older xcode)
  • iOS 9.3

Your input is welcome!

If you have any suggestions, please get in touch with us.
If you need help or found a bug, please open an issue.
If you have a new transition animation or want to contribute, please submit a pull request.

Let us know!

If you like BonsaiController, give it a ★ at the top right of this page.
Using BonsaiController in your app? Send us a link to your app in the app store!


Thank You

A special thank you to everyone that has contributed to this library to make it better. Your support is appreciated!


Developer: Warif Akhand Rishi, [email protected]
Designer: Takmila Tasmim Mim, [email protected]


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

Support Us

Buy Me A Coffee

Latest podspec

    "name": "BonsaiController",
    "version": "5.0.3",
    "summary": "ud83cudf32 Bonsai makes custom frame size and transition animation to any view controller",
    "description": "Add the ability to change custom frame size with cool transition animation to any view controller.",
    "homepage": "",
    "license": {
        "type": "MIT",
        "file": "LICENSE"
    "authors": {
        "Warif Akhand Rishi": "[email protected]"
    "source": {
        "git": "",
        "tag": "5.0.3"
    "swift_versions": "5",
    "platforms": {
        "ios": "9.3"
    "source_files": "BonsaiController/Classes/**/*"

Pin It on Pinterest

Share This