update-selectedBar-yposition-when-use-autolayout

This commit is contained in:
abeyuya 2016-10-04 14:00:26 +09:00
parent d12b4fa6c5
commit 9bdd6acfbc
1 changed files with 7 additions and 2 deletions

View File

@ -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