             }
         }
         
-        if width < self.frame.size.width {
-            toolbar.frame.size.width = self.frame.size.width
+        if width < frame.size.width {
+            toolbar.frame.size.width = frame.size.width
         } else {
             toolbar.frame.size.width = width
         }

    }
    
    private func setup() {
        self.autoresizingMask = .FlexibleWidth

        backgroundToolbar.frame = self.bounds
        backgroundToolbar.autoresizingMask = [.FlexibleHeight, .FlexibleWidth]

        toolbar.autoresizingMask = .FlexibleWidth
        toolbar.setBackgroundImage(UIImage(), forToolbarPosition: .Any, barMetrics: .Default)
        toolbar.setShadowImage(UIImage(), forToolbarPosition: .Any)

        toolbarScroll.frame = self.bounds
        toolbarScroll.autoresizingMask = [.FlexibleHeight, .FlexibleWidth]
        toolbarScroll.showsHorizontalScrollIndicator = false
        toolbarScroll.showsVerticalScrollIndicator = false
        toolbarScroll.backgroundColor = UIColor.clearColor()

        toolbarScroll.addSubview(toolbar)


        }
    }

    /**
        The tint color to apply to the toolbar background.
    */
    public var barTintColor: UIColor? {
        get { return backgroundToolbar.barTintColor }
        set { backgroundToolbar.barTintColor = newValue }
    }

    private var toolbarScroll: UIScrollView
    private var toolbar: UIToolbar
    private var backgroundToolbar: UIToolbar
