Tab Bar: Add a bottom separator
This commit is contained in:
@@ -121,6 +121,8 @@ class TabBarView: UIView
|
|||||||
private var activeTabIndex: Int = 0
|
private var activeTabIndex: Int = 0
|
||||||
private var tabContainerView = UIScrollView(frame: .zero)
|
private var tabContainerView = UIScrollView(frame: .zero)
|
||||||
|
|
||||||
|
private let bottomSeparatorView = UIView(frame: .zero)
|
||||||
|
|
||||||
override func sizeThatFits(_ size: CGSize) -> CGSize {
|
override func sizeThatFits(_ size: CGSize) -> CGSize {
|
||||||
CGSize(width: size.width, height: Self.preferredHeight)
|
CGSize(width: size.width, height: Self.preferredHeight)
|
||||||
}
|
}
|
||||||
@@ -132,6 +134,9 @@ class TabBarView: UIView
|
|||||||
backgroundColor = .secondarySystemGroupedBackground
|
backgroundColor = .secondarySystemGroupedBackground
|
||||||
tabContainerView.showsHorizontalScrollIndicator = false
|
tabContainerView.showsHorizontalScrollIndicator = false
|
||||||
tabContainerView.showsVerticalScrollIndicator = false
|
tabContainerView.showsVerticalScrollIndicator = false
|
||||||
|
|
||||||
|
addSubview(bottomSeparatorView)
|
||||||
|
bottomSeparatorView.backgroundColor = .systemFill
|
||||||
}
|
}
|
||||||
|
|
||||||
public func reloadTabs() {
|
public func reloadTabs() {
|
||||||
@@ -196,6 +201,12 @@ class TabBarView: UIView
|
|||||||
let tabContainerBounds = bounds
|
let tabContainerBounds = bounds
|
||||||
tabContainerView.frame = tabContainerBounds
|
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
|
let minimumTabWidth = { (traitCollection: UITraitCollection) -> CGFloat in
|
||||||
if traitCollection.horizontalSizeClass == .compact {
|
if traitCollection.horizontalSizeClass == .compact {
|
||||||
return tabContainerBounds.width / 3.0
|
return tabContainerBounds.width / 3.0
|
||||||
|
|||||||
Reference in New Issue
Block a user