polish code
This commit is contained in:
parent
7265c46b20
commit
b5478a2037
|
|
@ -14,7 +14,6 @@ public class BarExampleViewController: BarPagerTabStripViewController {
|
|||
|
||||
required public init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
isProgressiveIndicator = true
|
||||
}
|
||||
|
||||
public override func viewDidLoad() {
|
||||
|
|
@ -52,8 +51,9 @@ public class BarExampleViewController: BarPagerTabStripViewController {
|
|||
|
||||
public override func reloadPagerTabStripView() {
|
||||
isReload = true
|
||||
isProgressiveIndicator = (rand() % 2 == 0)
|
||||
isElasticIndicatorLimit = (rand() % 2 == 0)
|
||||
pagerOptions = rand() % 2 == 0 ? pagerOptions.union(.SkipIntermediateViewControllers) : (pagerOptions.remove(.SkipIntermediateViewControllers) ?? pagerOptions)
|
||||
pagerOptions = rand() % 2 == 0 ? pagerOptions.union(.IsProgressiveIndicator) : (pagerOptions.remove(.IsProgressiveIndicator) ?? pagerOptions)
|
||||
pagerOptions = rand() % 2 == 0 ? pagerOptions.union(.IsElasticIndicatorLimit) : (pagerOptions.remove(.IsElasticIndicatorLimit) ?? pagerOptions)
|
||||
super.reloadPagerTabStripView()
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -27,7 +27,7 @@ class ChildExampleViewController: UIViewController, PagerTabStripChildItem {
|
|||
|
||||
// MARK: - XLPagerTabStripViewControllerDelegate
|
||||
|
||||
func childHeaderForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> ChildHeaderData {
|
||||
return ChildHeaderData(title: "View", image: nil, highlightedImage: nil, color: .whiteColor())
|
||||
func childHeaderForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> ChildItemInfo {
|
||||
return ChildItemInfo(title: "View", image: nil, highlightedImage: nil, color: .whiteColor())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,54 +12,47 @@ import XLPagerTabStrip
|
|||
public class ReloadExampleViewController: UIViewController {
|
||||
@IBOutlet public var titleLabel: UILabel!
|
||||
|
||||
public lazy var bigLabel: UILabel = {
|
||||
let bigLabel = UILabel()
|
||||
bigLabel.backgroundColor = .clearColor()
|
||||
bigLabel.textColor = .whiteColor()
|
||||
bigLabel.font = UIFont.boldSystemFontOfSize(20)
|
||||
bigLabel.adjustsFontSizeToFitWidth = true
|
||||
return bigLabel
|
||||
}()
|
||||
|
||||
public override func viewDidLoad() {
|
||||
super.viewDidLoad()
|
||||
|
||||
if let _ = navigationController {
|
||||
let bigLabel = UILabel()
|
||||
bigLabel.backgroundColor = .clearColor()
|
||||
bigLabel.textColor = .whiteColor()
|
||||
bigLabel.font = UIFont.boldSystemFontOfSize(20)
|
||||
bigLabel.adjustsFontSizeToFitWidth = true
|
||||
navigationItem.titleView = bigLabel
|
||||
bigLabel.sizeToFit()
|
||||
}
|
||||
|
||||
for childViewController in childViewControllers {
|
||||
if let child = childViewController as? PagerTabStripViewController {
|
||||
updateTitle(child)
|
||||
break;
|
||||
}
|
||||
if let pagerViewController = childViewControllers.filter( { $0 is PagerTabStripViewController } ).first as? PagerTabStripViewController {
|
||||
updateTitle(pagerViewController)
|
||||
}
|
||||
}
|
||||
|
||||
@IBAction func reloadTapped(sender: UIBarButtonItem) {
|
||||
for childViewController in childViewControllers {
|
||||
if let child = childViewController as? PagerTabStripViewController {
|
||||
child.reloadPagerTabStripView()
|
||||
updateTitle(child)
|
||||
break;
|
||||
guard let child = childViewController as? PagerTabStripViewController else {
|
||||
continue
|
||||
}
|
||||
child.reloadPagerTabStripView()
|
||||
updateTitle(child)
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func updateTitle(pagerTabStripViewController: PagerTabStripViewController) -> Void {
|
||||
let title = String(format: "Progressive = \(stringFromBool(pagerTabStripViewController.isProgressiveIndicator)) ElasticLimit = \(stringFromBool(pagerTabStripViewController.isElasticIndicatorLimit))")
|
||||
titleLabel.text = title
|
||||
func updateTitle(pagerTabStripViewController: PagerTabStripViewController) {
|
||||
func stringFromBool(bool: Bool) -> String {
|
||||
return bool ? "YES" : "NO"
|
||||
}
|
||||
|
||||
if let titleview = navigationItem.titleView as? UILabel {
|
||||
titleview.text = title
|
||||
navigationItem.titleView?.sizeToFit()
|
||||
}
|
||||
titleLabel.text = "Progressive = \(stringFromBool(pagerTabStripViewController.pagerOptions.contains(.IsProgressiveIndicator))) ElasticLimit = \(stringFromBool(pagerTabStripViewController.pagerOptions.contains(.IsElasticIndicatorLimit)))"
|
||||
|
||||
(navigationItem.titleView as? UILabel)?.text = titleLabel.text
|
||||
navigationItem.titleView?.sizeToFit()
|
||||
}
|
||||
|
||||
func stringFromBool(bool: Bool) -> String {
|
||||
if bool {
|
||||
return "YES"
|
||||
}
|
||||
else {
|
||||
return "NO"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,8 +40,7 @@ public class SegmentedExampleViewController: SegmentedPagerTabStripViewControlle
|
|||
|
||||
@IBAction func reloadTapped(sender: UIBarButtonItem) {
|
||||
isReload = true
|
||||
isProgressiveIndicator = (rand() % 2 == 0)
|
||||
isElasticIndicatorLimit = (rand() % 2 == 0)
|
||||
pagerOptions = rand() % 2 == 0 ? pagerOptions.union(.SkipIntermediateViewControllers) : (pagerOptions.remove(.SkipIntermediateViewControllers) ?? pagerOptions)
|
||||
reloadPagerTabStripView()
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ class TableChildExampleViewController: UITableViewController, PagerTabStripChild
|
|||
|
||||
// MARK: - XLPagerTabStripChildItem
|
||||
|
||||
func childHeaderForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> ChildHeaderData {
|
||||
return ChildHeaderData(title: "Table View", image: nil, highlightedImage: nil, color: .whiteColor())
|
||||
func childHeaderForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> ChildItemInfo {
|
||||
return ChildItemInfo(title: "Table View", image: nil, highlightedImage: nil, color: .whiteColor())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -25,8 +25,9 @@
|
|||
import Foundation
|
||||
|
||||
public class BarPagerTabStripViewController: PagerTabStripViewController {
|
||||
|
||||
@IBOutlet lazy public var barView: BarView! = { [unowned self] in
|
||||
let barView = BarView(frame: CGRectMake(0, 0, self.view.frame.size.width, 5.0), optionsAmount: self.pagerTabStripChildViewControllers.count, selectedOptionIndex: self.currentIndex)
|
||||
let barView = BarView(frame: CGRectMake(0, 0, self.view.frame.size.width, 5.0))
|
||||
barView.backgroundColor = .orangeColor()
|
||||
barView.selectedBar.backgroundColor = .blackColor()
|
||||
barView.autoresizingMask = .FlexibleWidth
|
||||
|
|
@ -35,21 +36,17 @@ public class BarPagerTabStripViewController: PagerTabStripViewController {
|
|||
|
||||
public override func viewWillAppear(animated: Bool) {
|
||||
super.viewWillAppear(animated)
|
||||
|
||||
if let _ = barView.superview{
|
||||
barView.setOptionsAmount(optionsAmount: pagerTabStripChildViewControllers.count, animated: false)
|
||||
barView.moveToIndex(index: currentIndex, animated: false)
|
||||
}
|
||||
else{
|
||||
view.addSubview(barView!)
|
||||
if barView.superview == nil {
|
||||
view.addSubview(barView)
|
||||
}
|
||||
barView.optionsCount = pagerTabStripChildViewControllers.count
|
||||
barView.moveToIndex(index: currentIndex, animated: false)
|
||||
}
|
||||
|
||||
public override func reloadPagerTabStripView() {
|
||||
super.reloadPagerTabStripView()
|
||||
|
||||
barView.optionsCount = pagerTabStripChildViewControllers.count
|
||||
if isViewLoaded(){
|
||||
barView.setOptionsAmount(optionsAmount: pagerTabStripChildViewControllers.count, animated: false)
|
||||
barView.moveToIndex(index: currentIndex, animated: false)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,41 +24,42 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
public class BarView: UIView{
|
||||
public class BarView: UIView {
|
||||
|
||||
public lazy var selectedBar: UIView = { [unowned self] in
|
||||
let selectedBar = UIView(frame: CGRectMake(0, 0, self.frame.size.width, self.frame.size.height))
|
||||
return selectedBar
|
||||
}()
|
||||
|
||||
var optionsAmount: Int = 1
|
||||
var selectedOptionIndex: Int = 0
|
||||
var optionsCount = 1 {
|
||||
willSet(newOptionsCount) {
|
||||
if newOptionsCount <= selectedIndex {
|
||||
selectedIndex = optionsCount - 1
|
||||
}
|
||||
}
|
||||
}
|
||||
var selectedIndex = 0
|
||||
|
||||
required public init?(coder aDecoder: NSCoder) {
|
||||
super.init(coder: aDecoder)
|
||||
|
||||
addSubview(selectedBar)
|
||||
updateSelectedBarPositionWithAnimation(false)
|
||||
}
|
||||
|
||||
public init(frame: CGRect, optionsAmount: Int, selectedOptionIndex: Int) {
|
||||
self.optionsAmount = optionsAmount
|
||||
self.selectedOptionIndex = selectedOptionIndex
|
||||
override init(frame: CGRect) {
|
||||
super.init(frame: frame)
|
||||
|
||||
selectedBar = UIView(frame: CGRectMake(0, 0, self.frame.size.width, self.frame.size.height))
|
||||
addSubview(selectedBar)
|
||||
updateSelectedBarPositionWithAnimation(false)
|
||||
}
|
||||
|
||||
|
||||
// MARK: - Helpers
|
||||
|
||||
func updateSelectedBarPositionWithAnimation(animation: Bool) -> Void{
|
||||
private func updateSelectedBarPositionWithAnimation(animation: Bool) {
|
||||
var frame = selectedBar.frame
|
||||
frame.size.width = self.frame.size.width / CGFloat(optionsAmount)
|
||||
frame.origin.x = frame.size.width * CGFloat(selectedOptionIndex)
|
||||
if animation{
|
||||
UIView.animateWithDuration(0.3, animations: { () -> Void in
|
||||
self.selectedBar.frame = frame
|
||||
frame.size.width = self.frame.size.width / CGFloat(optionsCount)
|
||||
frame.origin.x = frame.size.width * CGFloat(selectedIndex)
|
||||
if animation {
|
||||
UIView.animateWithDuration(0.3, animations: { [weak self] in
|
||||
self?.selectedBar.frame = frame
|
||||
})
|
||||
}
|
||||
else{
|
||||
|
|
@ -66,16 +67,16 @@ public class BarView: UIView{
|
|||
}
|
||||
}
|
||||
|
||||
public func moveToIndex(index index: Int, animated: Bool) -> Void{
|
||||
selectedOptionIndex = index
|
||||
public func moveToIndex(index index: Int, animated: Bool) {
|
||||
selectedIndex = index
|
||||
updateSelectedBarPositionWithAnimation(animated)
|
||||
}
|
||||
|
||||
public func moveToIndex(fromIndex fromIndex: Int, toIndex: Int, progressPercentage: Float) -> Void {
|
||||
selectedOptionIndex = (progressPercentage > 0.5) ? toIndex : fromIndex
|
||||
public func moveToIndex(fromIndex fromIndex: Int, toIndex: Int, progressPercentage: Float) {
|
||||
selectedIndex = (progressPercentage > 0.5) ? toIndex : fromIndex
|
||||
|
||||
var newFrame = selectedBar.frame
|
||||
newFrame.size.width = frame.size.width / CGFloat(optionsAmount)
|
||||
newFrame.size.width = frame.size.width / CGFloat(optionsCount)
|
||||
var fromFrame = newFrame
|
||||
fromFrame.origin.x = newFrame.size.width * CGFloat(fromIndex)
|
||||
var toFrame = newFrame
|
||||
|
|
@ -85,17 +86,8 @@ public class BarView: UIView{
|
|||
selectedBar.frame = targetFrame
|
||||
}
|
||||
|
||||
public func setOptionsAmount(optionsAmount optionsAmount: Int, animated: Bool) -> Void {
|
||||
self.optionsAmount = optionsAmount
|
||||
|
||||
if optionsAmount <= selectedOptionIndex {
|
||||
selectedOptionIndex = optionsAmount - 1
|
||||
}
|
||||
|
||||
updateSelectedBarPositionWithAnimation(animated)
|
||||
}
|
||||
|
||||
public override func layoutSubviews() {
|
||||
super.layoutSubviews()
|
||||
updateSelectedBarPositionWithAnimation(false)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,52 @@
|
|||
// ChildItemInfo.swift
|
||||
// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip )
|
||||
//
|
||||
// Copyright (c) 2016 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
|
||||
|
||||
public struct ChildItemInfo {
|
||||
|
||||
public var title: String
|
||||
public var image: UIImage?
|
||||
// public var highlightedImage: UIImage?
|
||||
public var color: UIColor?
|
||||
|
||||
public init(title: String) {
|
||||
self.title = title
|
||||
}
|
||||
|
||||
public init(title: String, image: UIImage?) {
|
||||
self.init(title: title)
|
||||
self.image = image
|
||||
}
|
||||
|
||||
public init(title: String, image: UIImage?, highlightedImage: UIImage?) {
|
||||
self.init(title: title, image: image)
|
||||
// self.highlightedImage = highlightedImage
|
||||
}
|
||||
|
||||
public init(title: String, image: UIImage?, highlightedImage: UIImage?, color: UIColor?){
|
||||
self.init(title: title, image: image, highlightedImage: highlightedImage)
|
||||
self.color = color
|
||||
}
|
||||
}
|
||||
|
|
@ -0,0 +1,41 @@
|
|||
// PagerTabStripOptions.swift
|
||||
// XLPagerTabStrip ( https://github.com/xmartlabs/XLPagerTabStrip )
|
||||
//
|
||||
// Copyright (c) 2016 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
|
||||
|
||||
public struct PagerTabStripOptions : OptionSetType {
|
||||
|
||||
private enum PagerTabStripOption : Int {
|
||||
case SkipIntermediateViewControllers = 1, IsProgressiveIndicator = 2, IsElasticIndicatorLimit = 4
|
||||
}
|
||||
|
||||
public let rawValue: Int
|
||||
public init(rawValue: Int) { self.rawValue = rawValue }
|
||||
private init(_ option:PagerTabStripOption){ self.rawValue = option.rawValue }
|
||||
|
||||
public static let SkipIntermediateViewControllers = PagerTabStripOptions(.SkipIntermediateViewControllers)
|
||||
public static let IsProgressiveIndicator = PagerTabStripOptions(.IsProgressiveIndicator)
|
||||
public static let IsElasticIndicatorLimit = PagerTabStripOptions(.IsElasticIndicatorLimit)
|
||||
|
||||
}
|
||||
|
|
@ -25,35 +25,12 @@
|
|||
|
||||
import Foundation
|
||||
|
||||
public struct ChildHeaderData {
|
||||
|
||||
public var title: String
|
||||
public var image: UIImage?
|
||||
// public var highlightedImage: UIImage?
|
||||
public var color: UIColor?
|
||||
|
||||
public init(title: String) {
|
||||
self.title = title
|
||||
}
|
||||
|
||||
public init(title: String, image: UIImage?) {
|
||||
self.init(title: title)
|
||||
self.image = image
|
||||
}
|
||||
|
||||
public init(title: String, image: UIImage?, highlightedImage: UIImage?) {
|
||||
self.init(title: title, image: image)
|
||||
// self.highlightedImage = highlightedImage
|
||||
}
|
||||
|
||||
public init(title: String, image: UIImage?, highlightedImage: UIImage?, color: UIColor?){
|
||||
self.init(title: title, image: image, highlightedImage: highlightedImage)
|
||||
self.color = color
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: Protocols
|
||||
|
||||
|
||||
public protocol PagerTabStripChildItem {
|
||||
func childHeaderForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> ChildHeaderData
|
||||
func childHeaderForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) -> ChildItemInfo
|
||||
}
|
||||
|
||||
public protocol PagerTabStripViewControllerDelegate: class {
|
||||
|
|
@ -65,31 +42,25 @@ public protocol PagerTabStripViewControllerDataSource: class {
|
|||
func childViewControllersForPagerTabStripViewController(pagerTabStripController: PagerTabStripViewController) ->[UIViewController]
|
||||
}
|
||||
|
||||
|
||||
//MARK: PagerTabStripViewController
|
||||
|
||||
public class PagerTabStripViewController: UIViewController, UIScrollViewDelegate, PagerTabStripViewControllerDataSource, PagerTabStripViewControllerDelegate {
|
||||
private(set) var pagerTabStripChildViewControllers = [UIViewController]()
|
||||
|
||||
|
||||
@IBOutlet lazy public var containerView: UIScrollView! = { [unowned self] in
|
||||
let containerView = UIScrollView(frame: CGRectMake(0, 0, CGRectGetWidth(self.view.bounds), CGRectGetHeight(self.view.bounds)))
|
||||
containerView.autoresizingMask = [.FlexibleWidth, .FlexibleHeight]
|
||||
return containerView
|
||||
}()
|
||||
|
||||
public weak var delegate: PagerTabStripViewControllerDelegate?
|
||||
public weak var datasource: PagerTabStripViewControllerDataSource?
|
||||
|
||||
|
||||
public var pagerOptions = PagerTabStripOptions.SkipIntermediateViewControllers.union(.IsProgressiveIndicator).union(.IsElasticIndicatorLimit)
|
||||
|
||||
private(set) var pagerTabStripChildViewControllers = [UIViewController]()
|
||||
private(set) var currentIndex = 0
|
||||
public var skipIntermediateViewControllers = true
|
||||
public var isProgressiveIndicator = false
|
||||
public var isElasticIndicatorLimit = false
|
||||
|
||||
private var pagerTabStripChildViewControllersForScrolling : [UIViewController]?
|
||||
private var getPagerTabStripChildViewControllersForScrolling : [UIViewController] {
|
||||
return pagerTabStripChildViewControllersForScrolling ?? pagerTabStripChildViewControllers
|
||||
}
|
||||
|
||||
private var lastPageNumber = 0
|
||||
private var lastContentOffset: CGFloat = 0.0
|
||||
private var pageBeforeRotate = 0
|
||||
private var lastSize = CGSizeMake(0, 0)
|
||||
|
||||
|
||||
public var pageWidth: CGFloat {
|
||||
return CGRectGetWidth(containerView.bounds)
|
||||
|
|
@ -149,7 +120,7 @@ public class PagerTabStripViewController: UIViewController, UIScrollViewDelegate
|
|||
if !isViewLoaded() || view.window == nil {
|
||||
currentIndex = index
|
||||
}
|
||||
if animated && skipIntermediateViewControllers && abs(currentIndex - index) > 1 {
|
||||
if animated && pagerOptions.contains(.SkipIntermediateViewControllers) && abs(currentIndex - index) > 1 {
|
||||
var tmpChildViewControllers = pagerTabStripChildViewControllers
|
||||
let currentChildVC = pagerTabStripChildViewControllers[currentIndex]
|
||||
let fromIndex = currentIndex < index ? index - 1 : index + 1
|
||||
|
|
@ -306,7 +277,7 @@ public class PagerTabStripViewController: UIViewController, UIScrollViewDelegate
|
|||
currentIndex = newCurrentIndex
|
||||
let changeCurrentIndex = newCurrentIndex != oldCurrentIndex
|
||||
|
||||
if isProgressiveIndicator {
|
||||
if pagerOptions.contains(.IsProgressiveIndicator) {
|
||||
// FIXME: - check if delegate implements? pagerTabStripViewController(pagerTabStripViewController: XLPagerTabStripViewController, updateIndicatorFromIndex fromIndex: Int, toIndex index: Int, withProgressPercentage progressPercentage: Float, indexWasChanged changed: Bool)
|
||||
|
||||
let scrollPercentage = self.scrollPercentage()
|
||||
|
|
@ -344,7 +315,7 @@ public class PagerTabStripViewController: UIViewController, UIScrollViewDelegate
|
|||
}
|
||||
}
|
||||
|
||||
try! delegate?.pagerTabStripViewController(self, updateIndicatorFromIndex: fromIndex, toIndex: toIndex, withProgressPercentage: Float(isElasticIndicatorLimit ? scrollPercentage : (toIndex < 0 || toIndex >= getPagerTabStripChildViewControllersForScrolling.count ? CGFloat(0) : scrollPercentage)), indexWasChanged: changeCurrentIndex)
|
||||
try! delegate?.pagerTabStripViewController(self, updateIndicatorFromIndex: fromIndex, toIndex: toIndex, withProgressPercentage: Float(pagerOptions.contains(.IsElasticIndicatorLimit) ? scrollPercentage : (toIndex < 0 || toIndex >= getPagerTabStripChildViewControllersForScrolling.count ? CGFloat(0) : scrollPercentage)), indexWasChanged: changeCurrentIndex)
|
||||
}
|
||||
}
|
||||
else{
|
||||
|
|
@ -414,4 +385,15 @@ public class PagerTabStripViewController: UIViewController, UIScrollViewDelegate
|
|||
public override func willRotateToInterfaceOrientation(toInterfaceOrientation: UIInterfaceOrientation, duration: NSTimeInterval) {
|
||||
pageBeforeRotate = currentIndex
|
||||
}
|
||||
|
||||
|
||||
private var pagerTabStripChildViewControllersForScrolling : [UIViewController]?
|
||||
private var getPagerTabStripChildViewControllersForScrolling : [UIViewController] {
|
||||
return pagerTabStripChildViewControllersForScrolling ?? pagerTabStripChildViewControllers
|
||||
}
|
||||
private var lastPageNumber = 0
|
||||
private var lastContentOffset: CGFloat = 0.0
|
||||
private var pageBeforeRotate = 0
|
||||
private var lastSize = CGSizeMake(0, 0)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,11 @@
|
|||
objects = {
|
||||
|
||||
/* Begin PBXBuildFile section */
|
||||
281BFDC11C511C420090C26F /* ChildItemInfo.swift in Sources */ = {isa = PBXBuildFile; fileRef = 281BFDC01C511C420090C26F /* ChildItemInfo.swift */; };
|
||||
281BFDC31C511F120090C26F /* PagerTabStripOptions.swift in Sources */ = {isa = PBXBuildFile; fileRef = 281BFDC21C511F120090C26F /* PagerTabStripOptions.swift */; };
|
||||
287D0A6E1C4B73BD004566D6 /* XLPagerTabStripTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 287D0A6D1C4B73BD004566D6 /* XLPagerTabStripTests.swift */; };
|
||||
28E098BE1C5002D90083B788 /* PagerTabStripError.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28E098BD1C5002D90083B788 /* PagerTabStripError.swift */; };
|
||||
28E098C01C5003130083B788 /* PagerTabStripSwipeDirection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28E098BF1C5003130083B788 /* PagerTabStripSwipeDirection.swift */; };
|
||||
28E098C01C5003130083B788 /* SwipeDirection.swift in Sources */ = {isa = PBXBuildFile; fileRef = 28E098BF1C5003130083B788 /* SwipeDirection.swift */; };
|
||||
28F828811C494B2C00330CF4 /* XLPagerTabStrip.h in Headers */ = {isa = PBXBuildFile; fileRef = 28F828801C494B2C00330CF4 /* XLPagerTabStrip.h */; settings = {ATTRIBUTES = (Public, ); }; };
|
||||
28F828881C494B2C00330CF4 /* XLPagerTabStrip.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 28F8287D1C494B2C00330CF4 /* XLPagerTabStrip.framework */; };
|
||||
CB71C6EE1C4EB988008EC806 /* SegmentedPagerTabStripViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = CB71C6ED1C4EB988008EC806 /* SegmentedPagerTabStripViewController.swift */; };
|
||||
|
|
@ -29,9 +31,11 @@
|
|||
/* End PBXContainerItemProxy section */
|
||||
|
||||
/* Begin PBXFileReference section */
|
||||
281BFDC01C511C420090C26F /* ChildItemInfo.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = ChildItemInfo.swift; sourceTree = "<group>"; };
|
||||
281BFDC21C511F120090C26F /* PagerTabStripOptions.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PagerTabStripOptions.swift; sourceTree = "<group>"; };
|
||||
287D0A6D1C4B73BD004566D6 /* XLPagerTabStripTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = XLPagerTabStripTests.swift; path = Tests/XLPagerTabStripTests.swift; sourceTree = SOURCE_ROOT; };
|
||||
28E098BD1C5002D90083B788 /* PagerTabStripError.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PagerTabStripError.swift; sourceTree = "<group>"; };
|
||||
28E098BF1C5003130083B788 /* PagerTabStripSwipeDirection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = PagerTabStripSwipeDirection.swift; sourceTree = "<group>"; };
|
||||
28E098BF1C5003130083B788 /* SwipeDirection.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = SwipeDirection.swift; sourceTree = "<group>"; };
|
||||
28F8287D1C494B2C00330CF4 /* XLPagerTabStrip.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = XLPagerTabStrip.framework; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
28F828801C494B2C00330CF4 /* XLPagerTabStrip.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = XLPagerTabStrip.h; sourceTree = "<group>"; };
|
||||
28F828821C494B2C00330CF4 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
|
||||
|
|
@ -63,6 +67,24 @@
|
|||
/* End PBXFrameworksBuildPhase section */
|
||||
|
||||
/* Begin PBXGroup section */
|
||||
281BFDBE1C511B890090C26F /* Views */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CBA0A1FB1C502DA300C5748C /* BarView.swift */,
|
||||
);
|
||||
name = Views;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
281BFDBF1C511B9A0090C26F /* Controllers */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CBA0A1FA1C502DA300C5748C /* BarPagerTabStripViewController.swift */,
|
||||
CB86ED6A1C4D6E6C00DA463B /* PagerTabStripViewController.swift */,
|
||||
CB71C6ED1C4EB988008EC806 /* SegmentedPagerTabStripViewController.swift */,
|
||||
);
|
||||
name = Controllers;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
28F828731C494B2C00330CF4 = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
|
|
@ -105,12 +127,12 @@
|
|||
28F828971C494B4200330CF4 /* Sources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
CBA0A1FA1C502DA300C5748C /* BarPagerTabStripViewController.swift */,
|
||||
CBA0A1FB1C502DA300C5748C /* BarView.swift */,
|
||||
CB86ED6A1C4D6E6C00DA463B /* PagerTabStripViewController.swift */,
|
||||
CB71C6ED1C4EB988008EC806 /* SegmentedPagerTabStripViewController.swift */,
|
||||
281BFDBF1C511B9A0090C26F /* Controllers */,
|
||||
281BFDBE1C511B890090C26F /* Views */,
|
||||
28E098BD1C5002D90083B788 /* PagerTabStripError.swift */,
|
||||
28E098BF1C5003130083B788 /* PagerTabStripSwipeDirection.swift */,
|
||||
28E098BF1C5003130083B788 /* SwipeDirection.swift */,
|
||||
281BFDC01C511C420090C26F /* ChildItemInfo.swift */,
|
||||
281BFDC21C511F120090C26F /* PagerTabStripOptions.swift */,
|
||||
);
|
||||
path = Sources;
|
||||
sourceTree = "<group>";
|
||||
|
|
@ -223,11 +245,13 @@
|
|||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
CBA0A1FD1C502DA300C5748C /* BarView.swift in Sources */,
|
||||
281BFDC31C511F120090C26F /* PagerTabStripOptions.swift in Sources */,
|
||||
CBA0A1FC1C502DA300C5748C /* BarPagerTabStripViewController.swift in Sources */,
|
||||
CB71C6EE1C4EB988008EC806 /* SegmentedPagerTabStripViewController.swift in Sources */,
|
||||
28E098BE1C5002D90083B788 /* PagerTabStripError.swift in Sources */,
|
||||
281BFDC11C511C420090C26F /* ChildItemInfo.swift in Sources */,
|
||||
CB86ED6B1C4D6E6C00DA463B /* PagerTabStripViewController.swift in Sources */,
|
||||
28E098C01C5003130083B788 /* PagerTabStripSwipeDirection.swift in Sources */,
|
||||
28E098C01C5003130083B788 /* SwipeDirection.swift in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue