 //
 
 import Foundation
+import UIKit
 
 func SafeWrapViewController(controller: UIViewController,
                             navigationBarClass: AnyClass? = nil,
                             withPlaceholder: Bool = false,
                             backItem: UIBarButtonItem? = nil,
                             backTitle: String? = nil) -> UIViewController {
-    if !(controller is WrapperController) {
-        return WrapperController(controller: controller, navigationBarClass: navigationBarClass, withPlaceholderController: withPlaceholder, back: backItem, backTitle: backTitle)
+    if !(controller is WrapperViewController) {
+        return WrapperViewController(controller: controller, navigationBarClass: navigationBarClass, withPlaceholderController: withPlaceholder, back: backItem, backTitle: backTitle)
     }
     return controller
 }
 
 func SafeUnwrapViewController(controller: UIViewController) -> UIViewController {
     
-    if (controller is WrapperController) {
-        return (controller as! WrapperController).contentViewController
+    if (controller is WrapperViewController) {
+        return (controller as! WrapperViewController).contentViewController
     }
     return controller
 }
 
-public class RootNavigationController: UINavigationController {
-    // MARK: - Methods
-    weak var rt_delegate: UINavigationControllerDelegate?
-    var animationBlock: ((Bool) -> Void)?
+
+ class RootNavigationController: UINavigationController, UINavigationControllerDelegate {
+    fileprivate weak var rt_delegate: UINavigationControllerDelegate?
+    fileprivate var animationBlock: ((Bool) -> Void)?
 
     // TOOD: 加 is
    @IBInspectable var useSystemBackBarButtonItem = false
    @IBInspectable var transferNavigationBarAttributes = false
+    
+    var rt_topViewController: UIViewController {
+        return SafeUnwrapViewController(controller: super.topViewController!)
+    }
+    
     var rt_visibleViewController: UIViewController {
         return SafeUnwrapViewController(controller: super.visibleViewController!)
     }

                return SafeUnwrapViewController(controller: viewController)
            })
        }
        return []
    }
    
    override open func setViewControllers(_ viewControllers: [UIViewController], animated: Bool) {
        var vcs = [UIViewController]()
        for (index, viewController) in viewControllers.enumerated() {
            if self.useSystemBackBarButtonItem && index > 0 {

            self.animationBlock!(true)
            self.animationBlock = nil
        }
        self.rt_delegate?.navigationController!(navigationController, didShow: viewController, animated: animated)
    }
    
     func navigationControllerSupportedInterfaceOrientations(_ navigationController: UINavigationController) -> UIInterfaceOrientationMask {
        if self.rt_delegate != nil {
            return self.rt_delegate!.navigationControllerSupportedInterfaceOrientations!(navigationController)
        }
        return .all
    }
    
     func navigationControllerPreferredInterfaceOrientationForPresentation(_ navigationController: UINavigationController) -> UIInterfaceOrientation {
        if self.rt_delegate != nil {
            return self.rt_delegate!.navigationControllerPreferredInterfaceOrientationForPresentation!(navigationController)
        }
        return .portrait
    }
    
     func navigationController(_ navigationController: UINavigationController, interactionControllerFor animationController: UIViewControllerAnimatedTransitioning) -> UIViewControllerInteractiveTransitioning? {
        if self.rt_delegate != nil {
            return self.rt_delegate!.navigationController!(navigationController, interactionControllerFor: animationController)!
        }
        return nil
    }
    
     func navigationController(_ navigationController: UINavigationController, animationControllerFor operation: UINavigationControllerOperation, from fromVC: UIViewController, to toVC: UIViewController) -> UIViewControllerAnimatedTransitioning? {
        if self.rt_delegate != nil {
            return self.rt_delegate!.navigationController!(navigationController, animationControllerFor: operation, from: fromVC, to: toVC)
        }
