Tab Bar: Add a bottom separator

This commit is contained in:
James Magahern
2020-10-29 15:28:28 -07:00
parent 509cf66e18
commit 3d0f7e4f57

View File

@@ -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