From 68072ac521d86abc7a93cae62d9a4761cf92c488 Mon Sep 17 00:00:00 2001 From: James Magahern Date: Sun, 2 Aug 2020 12:07:07 -0700 Subject: [PATCH] Toolbar: button padding should be added to width for hit charge --- App/Titlebar and URL Bar/ToolbarViewController.swift | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/App/Titlebar and URL Bar/ToolbarViewController.swift b/App/Titlebar and URL Bar/ToolbarViewController.swift index 8dcd93e..b944c24 100644 --- a/App/Titlebar and URL Bar/ToolbarViewController.swift +++ b/App/Titlebar and URL Bar/ToolbarViewController.swift @@ -27,7 +27,7 @@ class ToolbarButtonView: UIView } override func sizeThatFits(_ size: CGSize) -> CGSize { - let width: CGFloat = buttonViews.reduce(0.0) { (result, button) -> CGFloat in + let width: CGFloat = buttonViews.reduce(buttonPadding / 2.0) { (result, button) -> CGFloat in return result + button.sizeThatFits(size).width + buttonPadding } @@ -36,14 +36,13 @@ class ToolbarButtonView: UIView override func layoutSubviews() { var buttonRect = CGRect(origin: .zero, size: CGSize(width: 0, height: bounds.height)) - buttonRect.origin.x = layoutMargins.left for button in buttonViews { let buttonSize = button.sizeThatFits(bounds.size) - buttonRect.size = CGSize(width: buttonSize.width, height: bounds.height) + buttonRect.size = CGSize(width: buttonSize.width + buttonPadding, height: bounds.height) button.frame = buttonRect - buttonRect.origin.x += buttonRect.width + buttonPadding + buttonRect.origin.x += buttonRect.width } } }