Toolbar: button padding should be added to width for hit charge

This commit is contained in:
James Magahern
2020-08-02 12:07:07 -07:00
parent e1a897aa1e
commit 68072ac521

View File

@@ -27,7 +27,7 @@ class ToolbarButtonView: UIView
} }
override func sizeThatFits(_ size: CGSize) -> CGSize { 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 return result + button.sizeThatFits(size).width + buttonPadding
} }
@@ -36,14 +36,13 @@ class ToolbarButtonView: UIView
override func layoutSubviews() { override func layoutSubviews() {
var buttonRect = CGRect(origin: .zero, size: CGSize(width: 0, height: bounds.height)) var buttonRect = CGRect(origin: .zero, size: CGSize(width: 0, height: bounds.height))
buttonRect.origin.x = layoutMargins.left
for button in buttonViews { for button in buttonViews {
let buttonSize = button.sizeThatFits(bounds.size) 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 button.frame = buttonRect
buttonRect.origin.x += buttonRect.width + buttonPadding buttonRect.origin.x += buttonRect.width
} }
} }
} }