updated tabs for logic on numberoflines
Signed-off-by: Matt Bruce <matt.bruce@verizon.com>
This commit is contained in:
parent
d3c3840ab3
commit
1986eceae2
@ -144,6 +144,10 @@ open class Tabs: View {
|
|||||||
orientation == .horizontal && fillContainer ? .center : .left
|
orientation == .horizontal && fillContainer ? .center : .left
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private var applyOverflow: Bool {
|
||||||
|
orientation == .horizontal && overflow == .scroll && !fillContainer
|
||||||
|
}
|
||||||
|
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
// MARK: - Initializers
|
// MARK: - Initializers
|
||||||
//--------------------------------------------------
|
//--------------------------------------------------
|
||||||
@ -258,7 +262,9 @@ open class Tabs: View {
|
|||||||
|
|
||||||
/// Updates the Tab individual views from local properties.
|
/// Updates the Tab individual views from local properties.
|
||||||
private func updateTabs() {
|
private func updateTabs() {
|
||||||
|
let numberOfLines = applyOverflow ? 1 : 0
|
||||||
for (index, tabItem) in tabViews.enumerated() {
|
for (index, tabItem) in tabViews.enumerated() {
|
||||||
|
tabItem.label.numberOfLines = numberOfLines
|
||||||
tabItem.size = size
|
tabItem.size = size
|
||||||
tabItem.isSelected = selectedIndex == index
|
tabItem.isSelected = selectedIndex == index
|
||||||
tabItem.index = index
|
tabItem.index = index
|
||||||
@ -277,10 +283,10 @@ open class Tabs: View {
|
|||||||
contentViewWidthConstraint?.isActive = false
|
contentViewWidthConstraint?.isActive = false
|
||||||
|
|
||||||
// Apply overflow
|
// Apply overflow
|
||||||
if orientation == .horizontal && overflow == .scroll && !fillContainer {
|
if applyOverflow {
|
||||||
let contentWidth = tabStackView.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize).width
|
|
||||||
contentViewWidthConstraint = nil
|
contentViewWidthConstraint = nil
|
||||||
scrollView.contentSize = CGSize(width: contentWidth, height: scrollView.bounds.height)
|
scrollView.contentSize = CGSize(width: tabStackView.systemLayoutSizeFitting(UIView.layoutFittingCompressedSize).width,
|
||||||
|
height: scrollView.bounds.height)
|
||||||
} else {
|
} else {
|
||||||
contentViewWidthConstraint = contentView.widthAnchor.constraint(equalTo: scrollView.widthAnchor)
|
contentViewWidthConstraint = contentView.widthAnchor.constraint(equalTo: scrollView.widthAnchor)
|
||||||
scrollView.contentSize = bounds.size
|
scrollView.contentSize = bounds.size
|
||||||
@ -294,6 +300,11 @@ open class Tabs: View {
|
|||||||
scrollToSelectedIndex(animated: true)
|
scrollToSelectedIndex(animated: true)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
open override func layoutSubviews() {
|
||||||
|
super.layoutSubviews()
|
||||||
|
updateContentView()
|
||||||
|
}
|
||||||
|
|
||||||
//update layout for borderline
|
//update layout for borderline
|
||||||
private func updateBorderline() {
|
private func updateBorderline() {
|
||||||
//borderLine
|
//borderLine
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user