From 9bdd6acfbccd62486745c6ae889e5efead27f24c Mon Sep 17 00:00:00 2001 From: abeyuya Date: Tue, 4 Oct 2016 14:00:26 +0900 Subject: [PATCH] update-selectedBar-yposition-when-use-autolayout --- Sources/ButtonBarView.swift | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) 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