Commit d12b0cb0 by Daniel Dahan

development: updated frame calculation for TabBar scroll view

parent 50a60baf
...@@ -215,8 +215,8 @@ open class TabBar: Bar { ...@@ -215,8 +215,8 @@ open class TabBar: Bar {
for b in buttons { for b in buttons {
let width = b.sizeThatFits(CGSize(width: CGFloat.greatestFiniteMagnitude, height: contentView.height)).width + interimSpace let width = b.sizeThatFits(CGSize(width: CGFloat.greatestFiniteMagnitude, height: contentView.height)).width + interimSpace
contentView.addSubview(b) scrollView.addSubview(b)
b.height = contentView.height b.height = scrollView.height
b.width = width b.width = width
b.x = w b.x = w
w += width w += width
...@@ -230,10 +230,12 @@ open class TabBar: Bar { ...@@ -230,10 +230,12 @@ open class TabBar: Bar {
centerViews = buttons centerViews = buttons
} }
scrollView.frame = contentView.bounds
if nil == selected { if nil == selected {
selected = buttons.first selected = buttons.first
} }
line.frame = CGRect(x: selected!.x, y: .bottom == lineAlignment ? height - lineHeight : 0, width: selected!.width, height: lineHeight) line.frame = CGRect(x: selected!.x, y: .bottom == lineAlignment ? height - lineHeight : 0, width: selected!.width, height: lineHeight)
} }
...@@ -260,7 +262,7 @@ extension TabBar { ...@@ -260,7 +262,7 @@ extension TabBar {
line.zPosition = 6000 line.zPosition = 6000
lineColor = Color.blue.base lineColor = Color.blue.base
lineHeight = 3 lineHeight = 3
addSubview(line) scrollView.addSubview(line)
} }
/// Prepares the divider. /// Prepares the divider.
......
...@@ -375,8 +375,7 @@ extension TabsController { ...@@ -375,8 +375,7 @@ extension TabsController {
return return
} }
let p = v.height let y = view.height - v.height
let y = view.height - p
v.width = view.width v.width = view.width
...@@ -472,7 +471,7 @@ extension TabsController { ...@@ -472,7 +471,7 @@ extension TabsController {
removeViewControllers() removeViewControllers()
prepareViewControllersForTransition(from: selectedIndex, to: i) // prepareViewControllersForTransition(from: selectedIndex, to: i)
selectedIndex = i selectedIndex = i
v.select(at: i) v.select(at: i)
...@@ -492,7 +491,7 @@ extension TabsController: UIScrollViewDelegate { ...@@ -492,7 +491,7 @@ extension TabsController: UIScrollViewDelegate {
removeViewControllers() removeViewControllers()
prepareViewControllers() prepareViewControllers()
prepareTabBar() // prepareTabBar()
layoutSubviews() layoutSubviews()
} }
} }
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment