 
     private lazy var extendingView = UIView()
     private lazy var backgroundView = TMBarBackgroundView(style: self.backgroundStyle)
+
+    private var hasExtendedEdges: Bool = false
     
     @available(*, unavailable)
     open override var backgroundColor: UIColor? {

    
    // MARK: Layout
    
    open override func didMoveToSuperview() {
        super.didMoveToSuperview()
        
        guard self.superview != nil else {
            return
        }
        guard let viewController = nextViewControllerInResponderChain() else {
            fatalError("TMNavigationBar could not find view controller to use for layout guides.")
        }
        
        superview?.layoutIfNeeded()
        
        var constraints = [
            extendingView.leadingAnchor.constraint(equalTo: leadingAnchor),

        if #available(iOS 11, *) {
            safeAreaInsets = viewController.view.safeAreaInsets
        } else {
            safeAreaInsets = UIEdgeInsets(top: viewController.topLayoutGuide.length,
                                          left: 0.0,
                                          bottom: viewController.bottomLayoutGuide.length,
                                          right: 0.0)
        }
        
        let relativeFrame = viewController.view.convert(self.frame, from: superview)
        if relativeFrame.origin.y == safeAreaInsets.top { // Pin to top anchor
            constraints.append(contentsOf: [
                extendingView.topAnchor.constraint(equalTo: viewController.view.topAnchor),
                extendingView.bottomAnchor.constraint(equalTo: bottomAnchor)
                ])
        } else if relativeFrame.maxY == (viewController.view.bounds.size.height - safeAreaInsets.bottom) { // Pin to bottom anchor
            constraints.append(contentsOf: [
                extendingView.topAnchor.constraint(equalTo: topAnchor),
                extendingView.bottomAnchor.constraint(equalTo: viewController.view.bottomAnchor)
