EMTransformableNavigationController 1.0.0

EMTransformableNavigationController 1.0.0

TestsTested
LangLanguage SwiftSwift
License MIT
ReleasedLast Release Aug 2017
SwiftSwift Version 3.0
SPMSupports SPM

Maintained by Martin Eberl.



  • By
  • Martin Eberl

EMTransformableNavigationController

Example

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

Requirements

Installation

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

pod 'EMTransformableNavigationController'

Author

Martin Eberl [email protected]

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 :)