Skip to content

Commit ad9ff17

Browse files
authored
Merge branch 'master' into AllowDisableNavBarCover
2 parents 968f4c5 + d244b43 commit ad9ff17

7 files changed

Lines changed: 37 additions & 12 deletions

File tree

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1+
# 0.2.7 Release notes (2017-04-13)
2+
3+
## Enhancements
4+
5+
* fixed bug
6+
17
# 0.2.6 Release notes (2017-03-30)
28

39
## Enhancements

Demo/TabPageViewControllerDemo/ViewController.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ class ViewController: UIViewController {
2929
tc.tabItems = [(vc1, "First"), (vc2, "Second")]
3030
var option = TabPageOption()
3131
option.tabWidth = view.frame.width / CGFloat(tc.tabItems.count)
32+
option.hidesTopViewOnSwipeType = .all
3233
tc.option = option
33-
tc.option.hidesTabBarOnSwipe = true
3434
navigationController?.pushViewController(tc, animated: true)
3535
}
3636

Sources/TabPageOption.swift

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@
88

99
import UIKit
1010

11+
public enum HidesTopContentsOnSwipeType {
12+
case none
13+
case tabBar
14+
case navigationBar
15+
case all
16+
}
17+
1118
public struct TabPageOption {
1219

1320
public init() {}
@@ -22,7 +29,7 @@ public struct TabPageOption {
2229
public var tabBackgroundColor: UIColor = .white
2330
public var pageBackgoundColor: UIColor = UIColor.white
2431
public var isTranslucent: Bool = true
25-
public var hidesTabBarOnSwipe: Bool = false
32+
public var hidesTopViewOnSwipeType: HidesTopContentsOnSwipeType = .none
2633
public var coverNavBar: Bool = false
2734

2835
internal var tabBarAlpha: CGFloat {

Sources/TabPageViewController.swift

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -240,12 +240,25 @@ extension TabPageViewController {
240240
public func updateNavigationBarHidden(_ hidden: Bool, animated: Bool) {
241241
guard let navigationController = navigationController else { return }
242242

243-
if option.hidesTabBarOnSwipe {
243+
switch option.hidesTopViewOnSwipeType {
244+
case .tabBar:
244245
updateTabBarOrigin(hidden: hidden)
246+
case .navigationBar:
247+
if hidden {
248+
navigationController.setNavigationBarHidden(true, animated: true)
249+
} else {
250+
showNavigationBar()
251+
}
252+
case .all:
253+
updateTabBarOrigin(hidden: hidden)
254+
if hidden {
255+
navigationController.setNavigationBarHidden(true, animated: true)
256+
} else {
257+
showNavigationBar()
258+
}
259+
default:
260+
break
245261
}
246-
247-
navigationController.setNavigationBarHidden(hidden, animated: animated)
248-
249262
if statusView == nil {
250263
setupStatusView()
251264
}
@@ -258,7 +271,7 @@ extension TabPageViewController {
258271
guard navigationController.isNavigationBarHidden else { return }
259272
guard let tabBarTopConstraint = tabBarTopConstraint else { return }
260273

261-
if option.hidesTabBarOnSwipe {
274+
if option.hidesTopViewOnSwipeType != .none {
262275
tabBarTopConstraint.constant = 0.0
263276
UIView.animate(withDuration: TimeInterval(UINavigationControllerHideShowBarDuration)) {
264277
self.view.layoutIfNeeded()

Sources/TabView.swift

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -255,9 +255,8 @@ extension TabView {
255255
if !animated && shouldScroll {
256256
cell.isCurrent = true
257257
}
258-
if !self.isInfinity {
259-
self.updateCollectionViewUserInteractionEnabled(true)
260-
}
258+
259+
self.updateCollectionViewUserInteractionEnabled(true)
261260
})
262261
}
263262
beforeIndex = currentIndex

TabPageViewController.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
Pod::Spec.new do |s|
1010
s.name = "TabPageViewController"
11-
s.version = "0.2.6"
11+
s.version = "0.2.7"
1212
s.summary = "Custom UIPageViewController"
1313

1414
# This description is used to generate tags and improve search results.

TabPageViewController.xcodeproj/TabPageViewController_Info.plist

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<key>CFBundlePackageType</key>
1616
<string>FMWK</string>
1717
<key>CFBundleShortVersionString</key>
18-
<string>0.2.6</string>
18+
<string>0.2.7</string>
1919
<key>CFBundleSignature</key>
2020
<string>????</string>
2121
<key>CFBundleVersion</key>

0 commit comments

Comments
 (0)