     }
 
     private func scrollUrlBar(dy: CGFloat) {
-        let newY = clamp(header.transform.ty + dy, min: -header.frame.height, max: 0)
+        let newY = clamp(header.transform.ty + dy, min: -ToolbarHeight, max: 0)
         header.transform = CGAffineTransformMakeTranslation(0, newY)
+        urlBar.alpha = (1 - newY / -ToolbarHeight)
     }
 
     private func scrollToobar(dy: CGFloat) {

    private func showToolbars(animated: Bool) {
        UIView.animateWithDuration(animated ? 0.5 : 0.0, animations: { () -> Void in
            self.header.transform = CGAffineTransformIdentity
            self.footer.transform = CGAffineTransformIdentity
            // Reset the insets so that clicking works on the edges of the screen
            if let tab = self.tabManager.selectedTab {


    private func hideToolbars(animated: Bool) {
        UIView.animateWithDuration(animated ? 0.5 : 0.0, animations: { () -> Void in
            self.header.transform = CGAffineTransformMakeTranslation(0, -ToolbarHeight)
            self.urlBar.alpha = 0
            self.footer.transform = CGAffineTransformMakeTranslation(0, self.footer.frame.height)
            // Reset the insets so that clicking works on the edges of the screen
            if let tab = self.tabManager.selectedTab {
                tab.webView.scrollView.contentInset = UIEdgeInsets(top: StatusBarHeight, left: 0, bottom: 0, right: 0)
                tab.webView.scrollView.scrollIndicatorInsets = UIEdgeInsets(top: StatusBarHeight, left: 0, bottom: 0, right: 0)
            }
        })
    }
