diff --git a/.travis.yml b/.travis.yml index 23a5264..1410bab 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,7 +1,7 @@ language: objective-c -osx_image: xcode9 +osx_image: xcode10 env: - - DESTINATION="OS=11.0,name=iPhone 7" SCHEME="XLPagerTabStrip" SDK=iphonesimulator + - DESTINATION="OS=12,name=iPhone 8" SCHEME="XLPagerTabStrip" SDK=iphonesimulator before_install: - brew update #- brew outdated carthage || brew upgrade carthage diff --git a/CHANGELOG.md b/CHANGELOG.md index 724b858..fd7ac0b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,6 +1,11 @@ # Change Log All notable changes to XLPagerTabStrip will be documented in this file. +### [8.0.1](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/8.0.1) + +* Bug fixes and stability improvements. +* Support for iPhone X. + ### [8.0.0](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/8.0.0) * Xcode 9 support. (Swift 4) @@ -8,7 +13,7 @@ All notable changes to XLPagerTabStrip will be documented in this file. ### [7.0.0](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/7.0.0) -* Bug fixes and stability improvements. +* Bug fixes and stability improvements. ### [6.0.0](https://github.com/xmartlabs/XLPagerTabStrip/releases/tag/6.0.0) diff --git a/Example.xcodeproj/project.pbxproj b/Example.xcodeproj/project.pbxproj index 60cd609..cb8534a 100644 --- a/Example.xcodeproj/project.pbxproj +++ b/Example.xcodeproj/project.pbxproj @@ -7,6 +7,9 @@ objects = { /* Begin PBXBuildFile section */ + 1F081A9E1FDABD1400B881EB /* YoutubeIconWithLabelCell.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F081A9B1FDABD1400B881EB /* YoutubeIconWithLabelCell.swift */; }; + 1F081A9F1FDABD1400B881EB /* YoutubeIconWithLabelCell.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1F081A9C1FDABD1400B881EB /* YoutubeIconWithLabelCell.xib */; }; + 1F081AA01FDABD1400B881EB /* YoutubeWithLabelExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 1F081A9D1FDABD1400B881EB /* YoutubeWithLabelExampleViewController.swift */; }; 285718181C568336004D7E7B /* DataProvider.swift in Sources */ = {isa = PBXBuildFile; fileRef = 285718171C568336004D7E7B /* DataProvider.swift */; }; 285DA2881C569AA2000908CA /* ChildExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 285DA2861C569AA2000908CA /* ChildExampleViewController.swift */; }; 285DA2891C569AA2000908CA /* TableChildExampleViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 285DA2871C569AA2000908CA /* TableChildExampleViewController.swift */; }; @@ -78,6 +81,9 @@ /* End PBXCopyFilesBuildPhase section */ /* Begin PBXFileReference section */ + 1F081A9B1FDABD1400B881EB /* YoutubeIconWithLabelCell.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YoutubeIconWithLabelCell.swift; sourceTree = ""; }; + 1F081A9C1FDABD1400B881EB /* YoutubeIconWithLabelCell.xib */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.xib; path = YoutubeIconWithLabelCell.xib; sourceTree = ""; }; + 1F081A9D1FDABD1400B881EB /* YoutubeWithLabelExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = YoutubeWithLabelExampleViewController.swift; sourceTree = ""; }; 285718171C568336004D7E7B /* DataProvider.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = DataProvider.swift; path = Example/Helpers/DataProvider.swift; sourceTree = ""; }; 285DA2861C569AA2000908CA /* ChildExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ChildExampleViewController.swift; path = Example/ChildControllers/ChildExampleViewController.swift; sourceTree = ""; }; 285DA2871C569AA2000908CA /* TableChildExampleViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = TableChildExampleViewController.swift; path = Example/ChildControllers/TableChildExampleViewController.swift; sourceTree = ""; }; @@ -125,6 +131,17 @@ /* End PBXFrameworksBuildPhase section */ /* Begin PBXGroup section */ + 1F081A9A1FDABD1400B881EB /* YoutubeWithLabel */ = { + isa = PBXGroup; + children = ( + 1F081A9B1FDABD1400B881EB /* YoutubeIconWithLabelCell.swift */, + 1F081A9C1FDABD1400B881EB /* YoutubeIconWithLabelCell.xib */, + 1F081A9D1FDABD1400B881EB /* YoutubeWithLabelExampleViewController.swift */, + ); + name = YoutubeWithLabel; + path = Example/YoutubeWithLabel; + sourceTree = ""; + }; 285718151C568285004D7E7B /* Helpers */ = { isa = PBXGroup; children = ( @@ -221,6 +238,7 @@ CB86ED6C1C4D6ED400DA463B /* Demo */ = { isa = PBXGroup; children = ( + 1F081A9A1FDABD1400B881EB /* YoutubeWithLabel */, 285DA2911C5A5945000908CA /* Youtube */, 285DA28E1C59C587000908CA /* Spotify */, 285DA28A1C59210F000908CA /* Instagram */, @@ -358,6 +376,7 @@ CB86ED801C4D6F0D00DA463B /* Assets.xcassets in Resources */, CB86ED941C4E89DD00DA463B /* PostCell.xib in Resources */, CBA0A2021C5032E100C5748C /* Storyboard.storyboard in Resources */, + 1F081A9F1FDABD1400B881EB /* YoutubeIconWithLabelCell.xib in Resources */, CB86ED811C4D6F0D00DA463B /* LaunchScreen.storyboard in Resources */, 285DA2971C5A6A36000908CA /* YoutubeIconCell.xib in Resources */, ); @@ -388,10 +407,12 @@ 285718181C568336004D7E7B /* DataProvider.swift in Sources */, CB2125DE1C52A80E002DAF42 /* TwitterExampleViewController.swift in Sources */, 285DA2891C569AA2000908CA /* TableChildExampleViewController.swift in Sources */, + 1F081A9E1FDABD1400B881EB /* YoutubeIconWithLabelCell.swift in Sources */, CBBD435F1C5274AE001A748E /* NavButtonBarExampleViewController.swift in Sources */, CB71C6F31C4FDDCE008EC806 /* PostCell.swift in Sources */, 285DA2931C5A596B000908CA /* YoutubeExampleViewController.swift in Sources */, 285DA2951C5A6A00000908CA /* YoutubeIconCell.swift in Sources */, + 1F081AA01FDABD1400B881EB /* YoutubeWithLabelExampleViewController.swift in Sources */, ); runOnlyForDeploymentPostprocessing = 0; }; diff --git a/Example/Example/Base.lproj/Storyboard.storyboard b/Example/Example/Base.lproj/Storyboard.storyboard index b0b9adb..94e103b 100644 --- a/Example/Example/Base.lproj/Storyboard.storyboard +++ b/Example/Example/Base.lproj/Storyboard.storyboard @@ -1,11 +1,11 @@ - + - + @@ -20,7 +20,7 @@ - + @@ -201,14 +201,14 @@ - + - + @@ -248,11 +248,11 @@ - + diff --git a/Example/Example/YoutubeWithLabel/YoutubeIconWithLabelCell.swift b/Example/Example/YoutubeWithLabel/YoutubeIconWithLabelCell.swift new file mode 100644 index 0000000..5371924 --- /dev/null +++ b/Example/Example/YoutubeWithLabel/YoutubeIconWithLabelCell.swift @@ -0,0 +1,33 @@ +// YoutubeIconWithLabelCell.swift +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) +// +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation +import UIKit + +class YoutubeIconWithLabelCell: UICollectionViewCell { + + @IBOutlet weak var iconImage: UIImageView! + @IBOutlet weak var iconLabel: UILabel! + +} diff --git a/Example/Example/YoutubeWithLabel/YoutubeIconWithLabelCell.xib b/Example/Example/YoutubeWithLabel/YoutubeIconWithLabelCell.xib new file mode 100644 index 0000000..bf501ad --- /dev/null +++ b/Example/Example/YoutubeWithLabel/YoutubeIconWithLabelCell.xib @@ -0,0 +1,55 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/Example/Example/YoutubeWithLabel/YoutubeWithLabelExampleViewController.swift b/Example/Example/YoutubeWithLabel/YoutubeWithLabelExampleViewController.swift new file mode 100644 index 0000000..c0893f4 --- /dev/null +++ b/Example/Example/YoutubeWithLabel/YoutubeWithLabelExampleViewController.swift @@ -0,0 +1,99 @@ +// YoutubeWithLabelExampleViewController.swift +// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip ) +// +// Copyright (c) 2017 Xmartlabs ( http://xmartlabs.com ) +// +// +// Permission is hereby granted, free of charge, to any person obtaining a copy +// of this software and associated documentation files (the "Software"), to deal +// in the Software without restriction, including without limitation the rights +// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell +// copies of the Software, and to permit persons to whom the Software is +// furnished to do so, subject to the following conditions: +// +// The above copyright notice and this permission notice shall be included in +// all copies or substantial portions of the Software. +// +// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, +// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN +// THE SOFTWARE. + +import Foundation +import XLPagerTabStrip + +class YoutubeWithLabelExampleViewController: BaseButtonBarPagerTabStripViewController { + + let redColor = UIColor(red: 221/255.0, green: 0/255.0, blue: 19/255.0, alpha: 1.0) + let unselectedIconColor = UIColor(red: 73/255.0, green: 8/255.0, blue: 10/255.0, alpha: 1.0) + + override init(nibName nibNameOrNil: String?, bundle nibBundleOrNil: Bundle?) { + super.init(nibName: nibNameOrNil, bundle: nibBundleOrNil) + } + + required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + + buttonBarItemSpec = ButtonBarItemSpec.nibFile(nibName: "YoutubeIconWithLabelCell", bundle: Bundle(for: YoutubeIconWithLabelCell.self), width: { _ in + return 70.0 + }) + } + + override func viewDidLoad() { + // change selected bar color + settings.style.buttonBarBackgroundColor = redColor + settings.style.buttonBarItemBackgroundColor = .clear + settings.style.selectedBarBackgroundColor = UIColor(red: 234/255.0, green: 234/255.0, blue: 234/255.0, alpha: 1.0) + settings.style.selectedBarHeight = 4.0 + settings.style.buttonBarMinimumLineSpacing = 0 + settings.style.buttonBarItemTitleColor = .black + settings.style.buttonBarItemsShouldFillAvailableWidth = true + settings.style.buttonBarLeftContentInset = 0 + settings.style.buttonBarRightContentInset = 0 + + changeCurrentIndexProgressive = { [weak self] (oldCell: YoutubeIconWithLabelCell?, newCell: YoutubeIconWithLabelCell?, progressPercentage: CGFloat, changeCurrentIndex: Bool, animated: Bool) -> Void in + guard changeCurrentIndex == true else { return } + oldCell?.iconImage.tintColor = self?.unselectedIconColor + oldCell?.iconLabel.textColor = self?.unselectedIconColor + newCell?.iconImage.tintColor = .white + newCell?.iconLabel.textColor = .white + } + super.viewDidLoad() + navigationController?.navigationBar.shadowImage = UIImage() + navigationController?.navigationBar.setBackgroundImage(UIImage(), for: .default) + } + + // MARK: - PagerTabStripDataSource + + override func viewControllers(for pagerTabStripController: PagerTabStripViewController) -> [UIViewController] { + let child_1 = TableChildExampleViewController(style: .plain, itemInfo: IndicatorInfo(title: " HOME", image: UIImage(named: "home"))) + let child_2 = TableChildExampleViewController(style: .plain, itemInfo: IndicatorInfo(title: " TRENDING", image: UIImage(named: "trending"))) + let child_3 = ChildExampleViewController(itemInfo: IndicatorInfo(title: " ACCOUNT", image: UIImage(named: "profile"))) + return [child_1, child_2, child_3] + } + + override func configure(cell: YoutubeIconWithLabelCell, for indicatorInfo: IndicatorInfo) { + cell.iconImage.image = indicatorInfo.image?.withRenderingMode(.alwaysTemplate) + cell.iconLabel.text = indicatorInfo.title?.trimmingCharacters(in: .whitespacesAndNewlines) + } + + override func updateIndicator(for viewController: PagerTabStripViewController, fromIndex: Int, toIndex: Int, withProgressPercentage progressPercentage: CGFloat, indexWasChanged: Bool) { + super.updateIndicator(for: viewController, fromIndex: fromIndex, toIndex: toIndex, withProgressPercentage: progressPercentage, indexWasChanged: indexWasChanged) + if indexWasChanged && toIndex > -1 && toIndex < viewControllers.count { + let child = viewControllers[toIndex] as! IndicatorInfoProvider // swiftlint:disable:this force_cast + UIView.performWithoutAnimation({ [weak self] () -> Void in + guard let me = self else { return } + me.navigationItem.leftBarButtonItem?.title = child.indicatorInfo(for: me).title + }) + } + } + + // MARK: - Actions + + @IBAction func closeAction(_ sender: UIButton) { + dismiss(animated: true, completion: nil) + } +} diff --git a/README.md b/README.md index 8e588b5..1fd961f 100644 --- a/README.md +++ b/README.md @@ -145,26 +145,26 @@ public var pagerBehaviour: PagerTabStripBehaviour ```swift public enum PagerTabStripBehaviour { - case Common(skipIntermediteViewControllers: Bool) - case Progressive(skipIntermediteViewControllers: Bool, elasticIndicatorLimit: Bool) + case common(skipIntermediteViewControllers: Bool) + case progressive(skipIntermediteViewControllers: Bool, elasticIndicatorLimit: Bool) } ``` Default Values: ```swift // Twitter Type -PagerTabStripBehaviour.Common(skipIntermediteViewControllers: true) +PagerTabStripBehaviour.common(skipIntermediateViewControllers: true) // Segmented Type -PagerTabStripBehaviour.Common(skipIntermediteViewControllers: true) +PagerTabStripBehaviour.common(skipIntermediateViewControllers: true) // Bar Type -PagerTabStripBehaviour.Progressive(skipIntermediteViewControllers: true, elasticIndicatorLimit: true) +PagerTabStripBehaviour.progressive(skipIntermediateViewControllers: true, elasticIndicatorLimit: true) // ButtonBar Type -PagerTabStripBehaviour.Progressive(skipIntermediteViewControllers: true, elasticIndicatorLimit: true)` +PagerTabStripBehaviour.progressive(skipIntermediateViewControllers: true, elasticIndicatorLimit: true) ``` -As you might have noticed `Common` and `Progressive` enumeration cases has `skipIntermediteViewControllers` and `elasticIndicatorLimit` associated values. +As you might have noticed `common` and `progressive` enumeration cases has `skipIntermediateViewControllers` and `elasticIndicatorLimit` associated values. -`skipIntermediteViewControllers` allows us to skip intermediate view controllers when a tab indicator is tapped. +`skipIntermediateViewControllers` allows us to skip intermediate view controllers when a tab indicator is tapped. `elasticIndicatorLimit` allows us to tension the indicator when we reach a limit, I mean when we try to move forward from last indicator or move back from first indicator. @@ -204,12 +204,12 @@ settings.style.buttonBarLeftContentInset: CGFloat? settings.style.buttonBarRightContentInset: CGFloat? // selected bar view is created programmatically so it's important to set up the following 2 properties properly -settings.style.selectedBarBackgroundColor = UIColor.blackColor() +settings.style.selectedBarBackgroundColor = UIColor.black settings.style.selectedBarHeight: CGFloat = 5 // each buttonBar item is a UICollectionView cell of type ButtonBarViewCell settings.style.buttonBarItemBackgroundColor: UIColor? -settings.style.buttonBarItemFont = UIFont.systemFontOfSize(18) +settings.style.buttonBarItemFont = UIFont.systemFont(ofSize: 18) // helps to determine the cell width, it represent the space before and after the title label settings.style.buttonBarItemLeftRightMargin: CGFloat = 8 settings.style.buttonBarItemTitleColor: UIColor? @@ -223,7 +223,7 @@ public var buttonBarHeight: CGFloat? ```swift override func viewDidLoad() { self.settings.style.selectedBarHeight = 2 - self.settings.style.selectedBarBackgroundColor = UIColor.whiteColor() + self.settings.style.selectedBarBackgroundColor = UIColor.white super.viewDidLoad() } @@ -245,17 +245,17 @@ changeCurrentIndexProgressive = { (oldCell: ButtonBarViewCell?, newCell: ButtonB guard changeCurrentIndex == true else { return } oldCell?.label.textColor = UIColor(white: 1, alpha: 0.6) - newCell?.label.textColor = .whiteColor() + newCell?.label.textColor = UIColor.white if animated { - UIView.animateWithDuration(0.1, animations: { () -> Void in - newCell?.transform = CGAffineTransformMakeScale(1.0, 1.0) - oldCell?.transform = CGAffineTransformMakeScale(0.8, 0.8) + UIView.animate(withDuration: 0.1, animations: { () -> Void in + newCell?.transform = CGAffineTransform(scaleX: 1.0, y: 1.0) + oldCell?.transform = CGAffineTransform(scaleX: 0.8, y: 0.8) }) } else { - newCell?.transform = CGAffineTransformMakeScale(1.0, 1.0) - oldCell?.transform = CGAffineTransformMakeScale(0.8, 0.8) + newCell?.transform = CGAffineTransform(scaleX: 1.0, y: 1.0) + oldCell?.transform = CGAffineTransform(scaleX: 0.8, y: 0.8) } } ``` @@ -273,10 +273,10 @@ settings.style.barHeight: CGFloat = 5 ```swift settings.style.dotColor = UIColor(white: 1, alpha: 0.4) -settings.style.selectedDotColor = UIColor.whiteColor() -settings.style.portraitTitleFont = UIFont.systemFontOfSize(18) -settings.style.landscapeTitleFont = UIFont.systemFontOfSize(15) -settings.style.titleColor = UIColor.whiteColor() +settings.style.selectedDotColor = UIColor.white +settings.style.portraitTitleFont = UIFont.systemFont(ofSize: 18) +settings.style.landscapeTitleFont = UIFont.systemFont(ofSize: 15) +settings.style.titleColor = UIColor.white ``` ### Segmented Type Customization @@ -290,7 +290,7 @@ settings.style.segmentedControlColor: UIColor? ## Requirements * iOS 8.0+ -* Xcode 8.0+ +* Xcode 9.3+ ## Examples diff --git a/Sources/BaseButtonBarPagerTabStripViewController.swift b/Sources/BaseButtonBarPagerTabStripViewController.swift index f4a3ce5..818d65f 100644 --- a/Sources/BaseButtonBarPagerTabStripViewController.swift +++ b/Sources/BaseButtonBarPagerTabStripViewController.swift @@ -131,6 +131,7 @@ open class BaseButtonBarPagerTabStripViewController IndexPath? in + .compactMap { (arg) -> IndexPath? in let (index, cell) = arg return cell == nil ? indexPaths[index] : nil } - .flatMap { (indexPath: IndexPath) -> IndexPath? in + .compactMap { (indexPath: IndexPath) -> IndexPath? in return (indexPath.item >= 0 && indexPath.item < buttonBarView.numberOfItems(inSection: indexPath.section)) ? indexPath : nil } @@ -323,6 +324,7 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa let indicatorInfo = childController.indicatorInfo(for: self) cell.label.text = indicatorInfo.title + cell.accessibilityLabel = indicatorInfo.accessibilityLabel cell.label.font = settings.style.buttonBarItemFont cell.label.textColor = settings.style.buttonBarItemTitleColor ?? cell.label.textColor cell.contentView.backgroundColor = settings.style.buttonBarItemBackgroundColor ?? cell.contentView.backgroundColor @@ -345,6 +347,9 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa changeCurrentIndex(currentIndex == indexPath.item ? nil : cell, currentIndex == indexPath.item ? cell : nil, false) } } + cell.isAccessibilityElement = true + cell.accessibilityLabel = cell.label.text + cell.accessibilityTraits.insert([.button, .header]) return cell } diff --git a/Sources/ButtonBarViewCell.swift b/Sources/ButtonBarViewCell.swift index f116577..4f60862 100644 --- a/Sources/ButtonBarViewCell.swift +++ b/Sources/ButtonBarViewCell.swift @@ -29,4 +29,24 @@ open class ButtonBarViewCell: UICollectionViewCell { @IBOutlet open var imageView: UIImageView! @IBOutlet open var label: UILabel! + public required init?(coder aDecoder: NSCoder) { + super.init(coder: aDecoder) + + isAccessibilityElement = true + accessibilityTraits.insert([.button, .header]) + } + + open override var isSelected: Bool { + get { + return super.isSelected + } + set { + super.isSelected = newValue + if (newValue) { + accessibilityTraits.insert(.selected) + } else { + accessibilityTraits.remove(.selected) + } + } + } } diff --git a/Sources/IndicatorInfo.swift b/Sources/IndicatorInfo.swift index a20f012..146eb9a 100644 --- a/Sources/IndicatorInfo.swift +++ b/Sources/IndicatorInfo.swift @@ -29,21 +29,34 @@ public struct IndicatorInfo { public var title: String? public var image: UIImage? public var highlightedImage: UIImage? + public var accessibilityLabel: String? public var userInfo: Any? public init(title: String?) { self.title = title + self.accessibilityLabel = title } public init(image: UIImage?, highlightedImage: UIImage? = nil, userInfo: Any? = nil) { self.image = image self.highlightedImage = highlightedImage + self.userInfo = userInfo } public init(title: String?, image: UIImage?, highlightedImage: UIImage? = nil, userInfo: Any? = nil) { self.title = title + self.accessibilityLabel = title self.image = image self.highlightedImage = highlightedImage + self.userInfo = userInfo + } + + public init(title: String?, accessibilityLabel:String?, image: UIImage?, highlightedImage: UIImage? = nil, userInfo: Any? = nil) { + self.title = title + self.accessibilityLabel = accessibilityLabel + self.image = image + self.highlightedImage = highlightedImage + self.userInfo = userInfo } } @@ -52,13 +65,16 @@ extension IndicatorInfo : ExpressibleByStringLiteral { public init(stringLiteral value: String) { title = value + accessibilityLabel = value } public init(extendedGraphemeClusterLiteral value: String) { title = value + accessibilityLabel = value } public init(unicodeScalarLiteral value: String) { title = value + accessibilityLabel = value } } diff --git a/Sources/PagerTabStripViewController.swift b/Sources/PagerTabStripViewController.swift index 6ae787f..d7e5551 100644 --- a/Sources/PagerTabStripViewController.swift +++ b/Sources/PagerTabStripViewController.swift @@ -105,16 +105,16 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate { reloadViewControllers() let childController = viewControllers[currentIndex] - addChildViewController(childController) + addChild(childController) childController.view.autoresizingMask = [.flexibleHeight, .flexibleWidth] containerView.addSubview(childController.view) - childController.didMove(toParentViewController: self) + childController.didMove(toParent: self) } open override func viewWillAppear(_ animated: Bool) { super.viewWillAppear(animated) isViewAppearing = true - childViewControllers.forEach { $0.beginAppearanceTransition(true, animated: animated) } + children.forEach { $0.beginAppearanceTransition(true, animated: animated) } } override open func viewDidAppear(_ animated: Bool) { @@ -126,17 +126,17 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate { moveToViewController(at: preCurrentIndex) } isViewAppearing = false - childViewControllers.forEach { $0.endAppearanceTransition() } + children.forEach { $0.endAppearanceTransition() } } open override func viewWillDisappear(_ animated: Bool) { super.viewWillDisappear(animated) - childViewControllers.forEach { $0.beginAppearanceTransition(false, animated: animated) } + children.forEach { $0.beginAppearanceTransition(false, animated: animated) } } open override func viewDidDisappear(_ animated: Bool) { super.viewDidDisappear(animated) - childViewControllers.forEach { $0.endAppearanceTransition() } + children.forEach { $0.endAppearanceTransition() } } override open func viewDidLayoutSubviews() { @@ -240,25 +240,25 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate { for (index, childController) in pagerViewControllers.enumerated() { let pageOffsetForChild = self.pageOffsetForChild(at: index) - if fabs(containerView.contentOffset.x - pageOffsetForChild) < containerView.bounds.width { + if abs(containerView.contentOffset.x - pageOffsetForChild) < containerView.bounds.width { if childController.parent != nil { childController.view.frame = CGRect(x: offsetForChild(at: index), y: 0, width: view.bounds.width, height: containerView.bounds.height) childController.view.autoresizingMask = [.flexibleHeight, .flexibleWidth] } else { childController.beginAppearanceTransition(true, animated: false) - addChildViewController(childController) + addChild(childController) childController.view.frame = CGRect(x: offsetForChild(at: index), y: 0, width: view.bounds.width, height: containerView.bounds.height) childController.view.autoresizingMask = [.flexibleHeight, .flexibleWidth] containerView.addSubview(childController.view) - childController.didMove(toParentViewController: self) + childController.didMove(toParent: self) childController.endAppearanceTransition() } } else { if childController.parent != nil { childController.beginAppearanceTransition(false, animated: false) - childController.willMove(toParentViewController: nil) + childController.willMove(toParent: nil) childController.view.removeFromSuperview() - childController.removeFromParentViewController() + childController.removeFromParent() childController.endAppearanceTransition() } } @@ -284,9 +284,9 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate { guard isViewLoaded else { return } for childController in viewControllers where childController.parent != nil { childController.beginAppearanceTransition(false, animated: false) - childController.willMove(toParentViewController: nil) + childController.willMove(toParent: nil) childController.view.removeFromSuperview() - childController.removeFromParentViewController() + childController.removeFromParent() childController.endAppearanceTransition() } reloadViewControllers() @@ -299,7 +299,7 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate { updateContent() } - // MARK: - UIScrollDelegate + // MARK: - UIScrollViewDelegate open func scrollViewDidScroll(_ scrollView: UIScrollView) { if containerView == scrollView { @@ -381,7 +381,7 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate { guard !viewControllers.isEmpty else { fatalError("viewControllers(for:) should provide at least one child view controller") } - viewControllers.forEach { if !($0 is IndicatorInfoProvider) { fatalError("Every view controller provided by PagerTabStripDataSource's viewControllers(for:) method must conform to InfoProvider") }} + viewControllers.forEach { if !($0 is IndicatorInfoProvider) { fatalError("Every view controller provided by PagerTabStripDataSource's viewControllers(for:) method must conform to IndicatorInfoProvider") }} } diff --git a/Sources/SegmentedPagerTabStripViewController.swift b/Sources/SegmentedPagerTabStripViewController.swift index 9c2baa3..cdd3fb1 100644 --- a/Sources/SegmentedPagerTabStripViewController.swift +++ b/Sources/SegmentedPagerTabStripViewController.swift @@ -57,7 +57,8 @@ open class SegmentedPagerTabStripViewController: PagerTabStripViewController, Pa open override func viewDidLoad() { super.viewDidLoad() - segmentedControl = segmentedControl ?? UISegmentedControl() + let auxSegmentedControl = segmentedControl ?? UISegmentedControl() + segmentedControl = auxSegmentedControl if segmentedControl.superview == nil { navigationItem.titleView = segmentedControl } diff --git a/XLPagerTabStrip.podspec b/XLPagerTabStrip.podspec index b94bae6..70a9d3f 100644 --- a/XLPagerTabStrip.podspec +++ b/XLPagerTabStrip.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = "XLPagerTabStrip" - s.version = "8.0.0" + s.version = "8.0.1" s.summary = "Android PagerTabStrip for iOS and much more." s.homepage = "https://github.com/xmartlabs/XLPagerTabStrip" s.license = { type: 'MIT', file: 'LICENSE' } @@ -9,7 +9,8 @@ Pod::Spec.new do |s| s.social_media_url = 'https://twitter.com/xmartlabs' s.ios.deployment_target = '8.0' s.requires_arc = true - s.ios.source_files = 'Sources/**/*' + s.ios.source_files = 'Sources/**/*.{h,m,swift}' s.ios.frameworks = 'UIKit', 'Foundation' s.resource_bundles = { 'XLPagerTabStrip' => ['Sources/ButtonCell.xib'] } + s.swift_version = "4.2" end diff --git a/XLPagerTabStrip.xcodeproj/project.pbxproj b/XLPagerTabStrip.xcodeproj/project.pbxproj index 01e8d21..9f455b3 100644 --- a/XLPagerTabStrip.xcodeproj/project.pbxproj +++ b/XLPagerTabStrip.xcodeproj/project.pbxproj @@ -379,7 +379,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = YES; ONLY_ACTIVE_ARCH = YES; SDKROOT = iphoneos; @@ -430,7 +430,7 @@ GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE; GCC_WARN_UNUSED_FUNCTION = YES; GCC_WARN_UNUSED_VARIABLE = YES; - IPHONEOS_DEPLOYMENT_TARGET = 9.0; + IPHONEOS_DEPLOYMENT_TARGET = 8.0; MTL_ENABLE_DEBUG_INFO = NO; SDKROOT = iphoneos; SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule"; @@ -458,7 +458,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -479,7 +479,7 @@ PRODUCT_NAME = "$(TARGET_NAME)"; SKIP_INSTALL = YES; SWIFT_SWIFT3_OBJC_INFERENCE = Default; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; @@ -492,7 +492,7 @@ PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.XLPagerTabStripTests; PRODUCT_NAME = "$(TARGET_NAME)"; SWIFT_OPTIMIZATION_LEVEL = "-Onone"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Debug; }; @@ -504,7 +504,7 @@ LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks"; PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.XLPagerTabStripTests; PRODUCT_NAME = "$(TARGET_NAME)"; - SWIFT_VERSION = 4.0; + SWIFT_VERSION = 4.2; }; name = Release; }; diff --git a/XLPagerTabStrip.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist b/XLPagerTabStrip.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist new file mode 100644 index 0000000..18d9810 --- /dev/null +++ b/XLPagerTabStrip.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist @@ -0,0 +1,8 @@ + + + + + IDEDidComputeMac32BitWarning + + +