diff --git a/Sources/ButtonBarView.swift b/Sources/ButtonBarView.swift index 9f63c0a..eacc0b1 100644 --- a/Sources/ButtonBarView.swift +++ b/Sources/ButtonBarView.swift @@ -47,7 +47,7 @@ open class ButtonBarView: UICollectionView { internal var selectedBarHeight: CGFloat = 4 { didSet { - updateSlectedBarYPosition() + updateSelectedBarYPosition() } } var selectedBarAlignment: SelectedBarAlignment = .center @@ -63,6 +63,11 @@ open class ButtonBarView: UICollectionView { addSubview(selectedBar) } + override open func layoutSubviews() { + super.layoutSubviews() + updateSelectedBarYPosition() + } + open func moveTo(index: Int, animated: Bool, swipeDirection: SwipeDirection, pagerScroll: PagerScroll) { selectedIndex = index updateSelectedBarPosition(animated, swipeDirection: swipeDirection, pagerScroll: pagerScroll) @@ -165,7 +170,7 @@ open class ButtonBarView: UICollectionView { return contentOffset } - private func updateSlectedBarYPosition() { + private func updateSelectedBarYPosition() { var selectedBarFrame = selectedBar.frame selectedBarFrame.origin.y = frame.size.height - selectedBarHeight selectedBarFrame.size.height = selectedBarHeight