From 3d0f7e4f57d7f46c9f7d52ac470c33ea14a1c6c3 Mon Sep 17 00:00:00 2001 From: James Magahern Date: Thu, 29 Oct 2020 15:28:28 -0700 Subject: [PATCH] Tab Bar: Add a bottom separator --- App/Tabs/TabBarView.swift | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/App/Tabs/TabBarView.swift b/App/Tabs/TabBarView.swift index dcb9704..9581038 100644 --- a/App/Tabs/TabBarView.swift +++ b/App/Tabs/TabBarView.swift @@ -121,6 +121,8 @@ class TabBarView: UIView private var activeTabIndex: Int = 0 private var tabContainerView = UIScrollView(frame: .zero) + private let bottomSeparatorView = UIView(frame: .zero) + override func sizeThatFits(_ size: CGSize) -> CGSize { CGSize(width: size.width, height: Self.preferredHeight) } @@ -132,6 +134,9 @@ class TabBarView: UIView backgroundColor = .secondarySystemGroupedBackground tabContainerView.showsHorizontalScrollIndicator = false tabContainerView.showsVerticalScrollIndicator = false + + addSubview(bottomSeparatorView) + bottomSeparatorView.backgroundColor = .systemFill } public func reloadTabs() { @@ -196,6 +201,12 @@ class TabBarView: UIView let tabContainerBounds = bounds tabContainerView.frame = tabContainerBounds + let separatorHeight = CGFloat(1.0) + bottomSeparatorView.frame = CGRect( + x: 0.0, y: bounds.height - separatorHeight, + width: bounds.width, height: separatorHeight + ) + let minimumTabWidth = { (traitCollection: UITraitCollection) -> CGFloat in if traitCollection.horizontalSizeClass == .compact { return tabContainerBounds.width / 3.0