Skip to content

Commit

Permalink
expose tabsView and centralize tabs buttons titles
Browse files Browse the repository at this point in the history
  • Loading branch information
hanynady committed Oct 10, 2018
1 parent 7cfd545 commit 1108395
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 5 deletions.
2 changes: 1 addition & 1 deletion Sources/ParallaxPagerView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ public final class ParallaxPagerView: UIView {
private var originalTopInset: CGFloat = 0.0

private var headerView = UIView()
private(set) var tabsView: (UIView & PagerTab)?
public private(set) var tabsView: (UIView & PagerTab)?

private var viewControllers = [TabViewController]()
private let hasShownController = NSHashTable<UIViewController>.weakObjects()
Expand Down
8 changes: 5 additions & 3 deletions Sources/Tabs/TabsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ fileprivate class TabView: UIView {
selectedColor: UIColor,
defaultFont: UIFont,
selectedFont: UIFont,
height: CGFloat,
tabsView: TabsView
) {
self.index = index
Expand All @@ -43,7 +44,7 @@ fileprivate class TabView: UIView {

self.title = title
let buttonFrame = button.frame
let frame = CGRect(x: 0, y: 0, width: buttonFrame.size.width, height: buttonFrame.size.height)
let frame = CGRect(x: 0, y: 0, width: buttonFrame.size.width, height: height)
super.init(frame: frame)
button.addTarget(self, action:#selector(tabClicked), for: .touchUpInside)
addSubview(button)
Expand Down Expand Up @@ -89,8 +90,8 @@ class TabsView: UIView {
let bundle = Bundle(identifier:"com.ParallaxPagerView.ParallaxPagerView-iOS")
let tabsView = bundle!.loadNibNamed("TabsView", owner: nil, options: nil)?.first as! TabsView
tabsView.tabsConfig = config
tabsView.createTabs()
tabsView.frame = CGRect(x: 0, y: 0, width: tabsView.frame.size.width, height: config.height)
tabsView.createTabs()
tabsView.setupSelectionIndicator()
return tabsView
}
Expand All @@ -112,6 +113,7 @@ class TabsView: UIView {
selectedColor: tabsConfig.selectedTabTitleColor,
defaultFont: tabsConfig.defaultTabTitleFont,
selectedFont: tabsConfig.selectedTabTitleFont,
height: self.frame.size.height,
tabsView: self
)

Expand Down Expand Up @@ -156,7 +158,7 @@ class TabsView: UIView {
let selectedTabFrame = tabsList[selectedIndex].frame
let frame = CGRect(
x: selectedTabFrame.origin.x,
y: selectedTabFrame.size.height,
y: selectedTabFrame.size.height - tabsConfig.selectionIndicatorHeight,
width: selectedTabFrame.size.width,
height: tabsConfig.selectionIndicatorHeight
)
Expand Down
2 changes: 1 addition & 1 deletion Sources/Tabs/TabsView.xib
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
<subviews>
<scrollView clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="scaleToFill" translatesAutoresizingMaskIntoConstraints="NO" id="n1r-Wd-YDF">
<rect key="frame" x="0.0" y="0.0" width="375" height="70"/>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
</scrollView>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="calibratedWhite"/>
Expand Down

0 comments on commit 1108395

Please sign in to comment.