Skip to content

Commit 56acdd9

Browse files
alexanderkhitevmats-claassen
authored andcommitted
updated to Swift 4.2 and added swift version to podspec (#617)
1 parent 1619ad4 commit 56acdd9

File tree

5 files changed

+22
-23
lines changed

5 files changed

+22
-23
lines changed

Sources/ButtonBarPagerTabStripViewController.swift

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -349,8 +349,7 @@ open class ButtonBarPagerTabStripViewController: PagerTabStripViewController, Pa
349349
}
350350
cell.isAccessibilityElement = true
351351
cell.accessibilityLabel = cell.label.text
352-
cell.accessibilityTraits |= UIAccessibilityTraitButton
353-
cell.accessibilityTraits |= UIAccessibilityTraitHeader
352+
cell.accessibilityTraits.insert([.button, .header])
354353
return cell
355354
}
356355

Sources/ButtonBarViewCell.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ open class ButtonBarViewCell: UICollectionViewCell {
3333
super.init(coder: aDecoder)
3434

3535
isAccessibilityElement = true
36-
accessibilityTraits |= UIAccessibilityTraitButton
37-
accessibilityTraits |= UIAccessibilityTraitHeader
36+
accessibilityTraits.insert([.button, .header])
3837
}
3938

4039
open override var isSelected: Bool {
@@ -44,9 +43,9 @@ open class ButtonBarViewCell: UICollectionViewCell {
4443
set {
4544
super.isSelected = newValue
4645
if (newValue) {
47-
accessibilityTraits |= UIAccessibilityTraitSelected
46+
accessibilityTraits.insert(.selected)
4847
} else {
49-
accessibilityTraits &= ~UIAccessibilityTraitSelected
48+
accessibilityTraits.remove(.selected)
5049
}
5150
}
5251
}

Sources/PagerTabStripViewController.swift

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -105,16 +105,16 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
105105
reloadViewControllers()
106106

107107
let childController = viewControllers[currentIndex]
108-
addChildViewController(childController)
108+
addChild(childController)
109109
childController.view.autoresizingMask = [.flexibleHeight, .flexibleWidth]
110110
containerView.addSubview(childController.view)
111-
childController.didMove(toParentViewController: self)
111+
childController.didMove(toParent: self)
112112
}
113113

114114
open override func viewWillAppear(_ animated: Bool) {
115115
super.viewWillAppear(animated)
116116
isViewAppearing = true
117-
childViewControllers.forEach { $0.beginAppearanceTransition(true, animated: animated) }
117+
children.forEach { $0.beginAppearanceTransition(true, animated: animated) }
118118
}
119119

120120
override open func viewDidAppear(_ animated: Bool) {
@@ -126,17 +126,17 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
126126
moveToViewController(at: preCurrentIndex)
127127
}
128128
isViewAppearing = false
129-
childViewControllers.forEach { $0.endAppearanceTransition() }
129+
children.forEach { $0.endAppearanceTransition() }
130130
}
131131

132132
open override func viewWillDisappear(_ animated: Bool) {
133133
super.viewWillDisappear(animated)
134-
childViewControllers.forEach { $0.beginAppearanceTransition(false, animated: animated) }
134+
children.forEach { $0.beginAppearanceTransition(false, animated: animated) }
135135
}
136136

137137
open override func viewDidDisappear(_ animated: Bool) {
138138
super.viewDidDisappear(animated)
139-
childViewControllers.forEach { $0.endAppearanceTransition() }
139+
children.forEach { $0.endAppearanceTransition() }
140140
}
141141

142142
override open func viewDidLayoutSubviews() {
@@ -240,25 +240,25 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
240240

241241
for (index, childController) in pagerViewControllers.enumerated() {
242242
let pageOffsetForChild = self.pageOffsetForChild(at: index)
243-
if fabs(containerView.contentOffset.x - pageOffsetForChild) < containerView.bounds.width {
243+
if abs(containerView.contentOffset.x - pageOffsetForChild) < containerView.bounds.width {
244244
if childController.parent != nil {
245245
childController.view.frame = CGRect(x: offsetForChild(at: index), y: 0, width: view.bounds.width, height: containerView.bounds.height)
246246
childController.view.autoresizingMask = [.flexibleHeight, .flexibleWidth]
247247
} else {
248248
childController.beginAppearanceTransition(true, animated: false)
249-
addChildViewController(childController)
249+
addChild(childController)
250250
childController.view.frame = CGRect(x: offsetForChild(at: index), y: 0, width: view.bounds.width, height: containerView.bounds.height)
251251
childController.view.autoresizingMask = [.flexibleHeight, .flexibleWidth]
252252
containerView.addSubview(childController.view)
253-
childController.didMove(toParentViewController: self)
253+
childController.didMove(toParent: self)
254254
childController.endAppearanceTransition()
255255
}
256256
} else {
257257
if childController.parent != nil {
258258
childController.beginAppearanceTransition(false, animated: false)
259-
childController.willMove(toParentViewController: nil)
259+
childController.willMove(toParent: nil)
260260
childController.view.removeFromSuperview()
261-
childController.removeFromParentViewController()
261+
childController.removeFromParent()
262262
childController.endAppearanceTransition()
263263
}
264264
}
@@ -284,9 +284,9 @@ open class PagerTabStripViewController: UIViewController, UIScrollViewDelegate {
284284
guard isViewLoaded else { return }
285285
for childController in viewControllers where childController.parent != nil {
286286
childController.beginAppearanceTransition(false, animated: false)
287-
childController.willMove(toParentViewController: nil)
287+
childController.willMove(toParent: nil)
288288
childController.view.removeFromSuperview()
289-
childController.removeFromParentViewController()
289+
childController.removeFromParent()
290290
childController.endAppearanceTransition()
291291
}
292292
reloadViewControllers()

XLPagerTabStrip.podspec

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ Pod::Spec.new do |s|
1212
s.ios.source_files = 'Sources/**/*.{h,m,swift}'
1313
s.ios.frameworks = 'UIKit', 'Foundation'
1414
s.resource_bundles = { 'XLPagerTabStrip' => ['Sources/ButtonCell.xib'] }
15+
s.swift_version = "4.2"
1516
end

XLPagerTabStrip.xcodeproj/project.pbxproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -458,7 +458,7 @@
458458
PRODUCT_NAME = "$(TARGET_NAME)";
459459
SKIP_INSTALL = YES;
460460
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
461-
SWIFT_VERSION = 4.0;
461+
SWIFT_VERSION = 4.2;
462462
};
463463
name = Debug;
464464
};
@@ -479,7 +479,7 @@
479479
PRODUCT_NAME = "$(TARGET_NAME)";
480480
SKIP_INSTALL = YES;
481481
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
482-
SWIFT_VERSION = 4.0;
482+
SWIFT_VERSION = 4.2;
483483
};
484484
name = Release;
485485
};
@@ -492,7 +492,7 @@
492492
PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.XLPagerTabStripTests;
493493
PRODUCT_NAME = "$(TARGET_NAME)";
494494
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
495-
SWIFT_VERSION = 4.0;
495+
SWIFT_VERSION = 4.2;
496496
};
497497
name = Debug;
498498
};
@@ -504,7 +504,7 @@
504504
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
505505
PRODUCT_BUNDLE_IDENTIFIER = com.xmartlabs.XLPagerTabStripTests;
506506
PRODUCT_NAME = "$(TARGET_NAME)";
507-
SWIFT_VERSION = 4.0;
507+
SWIFT_VERSION = 4.2;
508508
};
509509
name = Release;
510510
};

0 commit comments

Comments
 (0)