         get {
             if self.navigationController != nil {
                 return self.navigationController!.delegate
-            }
-            else {
+            } else {
                return super.delegate
             }
         }

    }
    
    
    override func popViewController(animated: Bool) -> UIViewController {
        if self.navigationController != nil {
            return self.navigationController!.popViewController(animated: animated)!
        }
        return super.popViewController(animated: animated)!
    }
    override func popToRootViewController(animated: Bool) -> [UIViewController]? {
        if self.navigationController != nil {
            return self.navigationController!.popToRootViewController(animated: animated)!
        }
        return super.popToRootViewController(animated: animated)!
    }
    
    override func popToViewController(_ viewController: UIViewController, animated: Bool) -> [UIViewController]? {
        if self.navigationController != nil {
            return self.navigationController!.popToViewController(viewController, animated: animated)!
        }
        return super.popToViewController(viewController, animated: animated)!
    }
    
    override func setViewControllers(_ viewControllers: [UIViewController], animated: Bool) {

//

import Foundation
import UIKit

internal class WrapperNavigationController: UINavigationController {
    
    required override init(navigationBarClass: AnyClass?, toolbarClass: AnyClass?) {
        super.init(navigationBarClass: navigationBarClass, toolbarClass: toolbarClass)
    }
    
    required init?(coder aDecoder: NSCoder) {
        super.init(coder: aDecoder)
    }
    
    required override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) {
        super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil)
    }
    
    override init(rootViewController: UIViewController) {
        super.init(navigationBarClass: rootViewController.navigationBarClass, toolbarClass: nil)
        self.pushViewController(rootViewController, animated: false)
    }
    
    override func viewDidLoad() {
        super.viewDidLoad()
        self.interactivePopGestureRecognizer?.isEnabled = false
        if let mainNavigationController = self.rt_navigationController,
            mainNavigationController.transferNavigationBarAttributes {
            self.navigationBar.isTranslucent                = self.navigationController!.navigationBar.isTranslucent
            self.navigationBar.tintColor                    = self.navigationController!.navigationBar.tintColor
            self.navigationBar.barTintColor                 = self.navigationController?.navigationBar.barTintColor
            self.navigationBar.barStyle                     = self.navigationController!.navigationBar.barStyle
            self.navigationBar.backgroundColor              = self.navigationController!.navigationBar.backgroundColor
            self.navigationBar.titleTextAttributes          = self.navigationController!.navigationBar.titleTextAttributes
            self.navigationBar.shadowImage                  = self.navigationController!.navigationBar.shadowImage
            self.navigationBar.backIndicatorImage           = self.navigationController!.navigationBar.backIndicatorImage
            self.navigationBar.backIndicatorTransitionMaskImage = self.navigationController!.navigationBar.backIndicatorTransitionMaskImage
            
            self.navigationBar.setBackgroundImage(self.navigationController?.navigationBar.backgroundImage(for: .default), for: .default)
            self.navigationBar.setTitleVerticalPositionAdjustment(self.navigationController!.navigationBar.titleVerticalPositionAdjustment(for: .default), for: .default)
        }
        self.view.layoutIfNeeded()
    }
    
   override var tabBarController: UITabBarController? {
        let superTabBarController = super.tabBarController
        let navigationController = self.rt_navigationController
        if (superTabBarController != nil) {
            if let tabBarController = navigationController?.tabBarController,
                tabBarController != superTabBarController {
                return superTabBarController
            } else {
                let BoolValue = navigationController!.rt_viewControllers.any({ (viewController) -> Bool in
                    return viewController.hidesBottomBarWhenPushed
                })
                if !superTabBarController!.tabBar.isTranslucent || BoolValue {
                    return nil
                } else {
                    return superTabBarController
                }
            }
        }
