diff --git a/Example/Pageboy-Example.xcodeproj/project.pbxproj b/Example/Pageboy-Example.xcodeproj/project.pbxproj index 4ba5ea48..70c63890 100644 --- a/Example/Pageboy-Example.xcodeproj/project.pbxproj +++ b/Example/Pageboy-Example.xcodeproj/project.pbxproj @@ -18,6 +18,7 @@ D681E3541E549F7E007C08F5 /* PageViewControllerAppearance.swift in Sources */ = {isa = PBXBuildFile; fileRef = D681E3531E549F7E007C08F5 /* PageViewControllerAppearance.swift */; }; D681E3561E54ABE8007C08F5 /* TransparentNavigationBar.swift in Sources */ = {isa = PBXBuildFile; fileRef = D681E3551E54ABE8007C08F5 /* TransparentNavigationBar.swift */; }; D6ECCEC61E51B6FB00E9D5B3 /* ChildViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = D6ECCEC51E51B6FB00E9D5B3 /* ChildViewController.swift */; }; + E8F663AB1E9C387D00F601AC /* NavigationControllerUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = E8F663AA1E9C387D00F601AC /* NavigationControllerUtils.swift */; }; /* End PBXBuildFile section */ /* Begin PBXContainerItemProxy section */ @@ -71,6 +72,7 @@ D681E3531E549F7E007C08F5 /* PageViewControllerAppearance.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PageViewControllerAppearance.swift; sourceTree = ""; }; D681E3551E54ABE8007C08F5 /* TransparentNavigationBar.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TransparentNavigationBar.swift; sourceTree = ""; }; D6ECCEC51E51B6FB00E9D5B3 /* ChildViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChildViewController.swift; sourceTree = ""; }; + E8F663AA1E9C387D00F601AC /* NavigationControllerUtils.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = NavigationControllerUtils.swift; sourceTree = ""; }; /* End PBXFileReference section */ /* Begin PBXFrameworksBuildPhase section */ @@ -140,6 +142,7 @@ D681E3531E549F7E007C08F5 /* PageViewControllerAppearance.swift */, D681E3501E54959B007C08F5 /* GradientView.swift */, D681E3551E54ABE8007C08F5 /* TransparentNavigationBar.swift */, + E8F663AA1E9C387D00F601AC /* NavigationControllerUtils.swift */, ); name = "Example Components"; sourceTree = ""; @@ -247,6 +250,7 @@ D681E3541E549F7E007C08F5 /* PageViewControllerAppearance.swift in Sources */, D681E3511E54959B007C08F5 /* GradientView.swift in Sources */, D6ECCEC61E51B6FB00E9D5B3 /* ChildViewController.swift in Sources */, + E8F663AB1E9C387D00F601AC /* NavigationControllerUtils.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Example/Pageboy-Example/NavigationControllerUtils.swift b/Example/Pageboy-Example/NavigationControllerUtils.swift new file mode 100644 index 00000000..288bd5dc --- /dev/null +++ b/Example/Pageboy-Example/NavigationControllerUtils.swift @@ -0,0 +1,19 @@ +// +// NavigationControllerUtils.swift +// Pageboy-Example +// +// Created by Merrick Sapsford on 10/04/2017. +// Copyright © 2017 Merrick Sapsford. All rights reserved. +// + +import UIKit + +extension UINavigationController { + + open override var preferredStatusBarStyle: UIStatusBarStyle { + if let rootViewController = self.viewControllers.first { + return rootViewController.preferredStatusBarStyle + } + return super.preferredStatusBarStyle + } +} diff --git a/Pageboy.podspec b/Pageboy.podspec index 43485642..4e3529af 100644 --- a/Pageboy.podspec +++ b/Pageboy.podspec @@ -4,7 +4,7 @@ Pod::Spec.new do |s| s.platform = :ios, "9.0" s.requires_arc = true - s.version = "1.0.1" + s.version = "1.0.2" s.summary = "A simple, highly informative page view controller." s.description = <<-DESC A page view controller that provides simplified data source management, enhanced delegation and other useful features. diff --git a/Sources/Pageboy/Info.plist b/Sources/Pageboy/Info.plist index 33e6e911..f8f0fcfb 100644 --- a/Sources/Pageboy/Info.plist +++ b/Sources/Pageboy/Info.plist @@ -15,7 +15,7 @@ CFBundlePackageType FMWK CFBundleShortVersionString - 1.0.1 + 1.0.2 CFBundleVersion AUTO_GENERATED NSPrincipalClass diff --git a/Sources/Pageboy/PageboyViewController.swift b/Sources/Pageboy/PageboyViewController.swift index 15229f8f..5c51436a 100644 --- a/Sources/Pageboy/PageboyViewController.swift +++ b/Sources/Pageboy/PageboyViewController.swift @@ -106,7 +106,7 @@ open class PageboyViewController: UIViewController { internal var pageViewController: UIPageViewController! internal var previousPagePosition: CGFloat? internal var expectedTransitionIndex: Int? - + // // MARK: Properties // @@ -122,6 +122,22 @@ open class PageboyViewController: UIViewController { } } + /// Preferred status bar style of the current view controller. + open override var preferredStatusBarStyle: UIStatusBarStyle { + if let currentViewController = self.currentViewController { + return currentViewController.preferredStatusBarStyle + } + return super.preferredStatusBarStyle + } + + /// Preferred status bar hidden of the current view controller. + open override var prefersStatusBarHidden: Bool { + if let currentViewController = self.currentViewController { + return currentViewController.prefersStatusBarHidden + } + return super.prefersStatusBarHidden + } + /// The object that is the data source for the page view controller. (Defaults to self) public weak var dataSource: PageboyViewControllerDataSource? { didSet { @@ -183,6 +199,10 @@ open class PageboyViewController: UIViewController { public internal(set) var currentIndex: Int? { didSet { guard let currentIndex = self.currentIndex else { return } + + UIView.animate(withDuration: 0.3) { + self.setNeedsStatusBarAppearanceUpdate() + } // ensure position keeps in sync self.currentPosition = CGPoint(x: self.navigationOrientation == .horizontal ? CGFloat(currentIndex) : 0.0, @@ -193,6 +213,7 @@ open class PageboyViewController: UIViewController { didScrollToPageAtIndex: currentIndex, direction: direction, animated: self.isScrollingAnimated) + } } @@ -341,6 +362,7 @@ internal extension PageboyViewController { pageViewController.dataSource = self self.pageViewController = pageViewController + self.addChildViewController(pageViewController) self.view.addSubview(pageViewController.view) pageViewController.view.pageboyPinToSuperviewEdges() self.view.sendSubview(toBack: pageViewController.view)