Skip to content

EMart86/EMTransformableNavigationController

Repository files navigation

EMTransformableNavigationController

CI Status Version License Platform

Screenshot

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Installation

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

pod 'EMTransformableNavigationController'

Author

Martin Eberl eberl_ma@gmx.at

License

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

Example

Simply add the NavigationController to your view controller

override func viewDidLoad() {
    super.viewDidLoad()
    
    createAndAddTransformableViewController()
}

private func createAndAddTransformableViewController() {
    let viewController = UIViewController() //use any viewController
    viewController.view.backgroundColor = .lightGray
    let navigationController = EMTransformableNavigationController(rootViewController: viewController)
    navigationController.add(to: self)
}

A more convenient way to add a viewController is with the motion shake gesture

override func motionEnded(_ motion: UIEventSubtype, with event: UIEvent?) {
    if motion == .motionShake {
        createTransformableNavigationController()
    }
}

To remove the viewController, simply call

    transformableNavigationController.removeFromParentViewController() 
    //of course the navigationController needed to be stored in a proterty which we called transformableNavigationController

If you don't want the user to move out of the visible frame, simply set following property (defaulf is nil, which allowes the user to drag the navigation controller out of the bounds)

transformableNavigationController.allowedFrame = view.bounds

If you think, the user should be allowed to only shrink your view to a specific size, simply set following property (default is 100x100 px)

transformableNavigationController.minViewSize = CGSize(width: 300, height: 150)

If you were wondering if all this works with autolayout; it does, i just tested it :)

About

When you want to add a navigation controller to your app, that can be dragged and pinched

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published