Skip to content

Commit 55a3d78

Browse files
Convert code in Swift 4.2
1 parent 8beb51e commit 55a3d78

13 files changed

+76
-74
lines changed

M13Checkbox Demo/AppDelegate.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class AppDelegate: UIResponder, UIApplicationDelegate {
1616
var window: UIWindow?
1717

1818

19-
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
19+
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
2020
return true
2121
}
2222

M13Checkbox Demo/CollectionViewLayout.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ class CollectionViewLayout: UICollectionViewFlowLayout {
6363

6464

6565

66-
collectionView.decelerationRate = UIScrollViewDecelerationRateFast
66+
collectionView.decelerationRate = .fast
6767
}
6868

6969
//----------------------------

M13Checkbox Demo/DemoViewController.swift

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -97,21 +97,21 @@ class DemoViewController: UIViewController, UICollectionViewDataSource, UIPopove
9797

9898
switch checkbox!.stateChangeAnimation {
9999
case .stroke:
100-
cell.selectionButton?.setTitle("Stroke", for: UIControlState())
100+
cell.selectionButton?.setTitle("Stroke", for: UIControl.State())
101101
case .fill:
102-
cell.selectionButton?.setTitle("Fill", for: UIControlState())
102+
cell.selectionButton?.setTitle("Fill", for: UIControl.State())
103103
case .bounce:
104-
cell.selectionButton?.setTitle("Bounce", for: UIControlState())
104+
cell.selectionButton?.setTitle("Bounce", for: UIControl.State())
105105
case .expand:
106-
cell.selectionButton?.setTitle("Expand", for: UIControlState())
106+
cell.selectionButton?.setTitle("Expand", for: UIControl.State())
107107
case .flat:
108-
cell.selectionButton?.setTitle("Flat", for: UIControlState())
108+
cell.selectionButton?.setTitle("Flat", for: UIControl.State())
109109
case .spiral:
110-
cell.selectionButton?.setTitle("Spiral", for: UIControlState())
110+
cell.selectionButton?.setTitle("Spiral", for: UIControl.State())
111111
case .fade:
112-
cell.selectionButton?.setTitle("Fade", for: UIControlState())
112+
cell.selectionButton?.setTitle("Fade", for: UIControl.State())
113113
case .dot:
114-
cell.selectionButton?.setTitle("Dot", for: UIControlState())
114+
cell.selectionButton?.setTitle("Dot", for: UIControl.State())
115115
}
116116

117117
cell.selectionButton?.addTarget(self, action: #selector(DemoViewController.updateAnimation(_:)), for: .touchUpInside)
@@ -368,7 +368,7 @@ class DemoViewController: UIViewController, UICollectionViewDataSource, UIPopove
368368

369369

370370

371-
let position: UICollectionViewScrollPosition = layout.scrollDirection == .horizontal ? .centeredHorizontally : .centeredVertically
371+
let position: UICollectionView.ScrollPosition = layout.scrollDirection == .horizontal ? .centeredHorizontally : .centeredVertically
372372
collectionView.scrollToItem(at: indexPath, at: position, animated: true)
373373
}
374374

@@ -499,21 +499,21 @@ class DemoViewController: UIViewController, UICollectionViewDataSource, UIPopove
499499
if let cell = collectionView?.cellForItem(at: IndexPath(item: 1, section: 0)) as? SelectionCollectionViewCell {
500500
switch animation {
501501
case .stroke:
502-
cell.selectionButton?.setTitle("Stroke", for: UIControlState())
502+
cell.selectionButton?.setTitle("Stroke", for: UIControl.State())
503503
case .fill:
504-
cell.selectionButton?.setTitle("Fill", for: UIControlState())
504+
cell.selectionButton?.setTitle("Fill", for: UIControl.State())
505505
case .bounce:
506-
cell.selectionButton?.setTitle("Bounce", for: UIControlState())
506+
cell.selectionButton?.setTitle("Bounce", for: UIControl.State())
507507
case .expand:
508-
cell.selectionButton?.setTitle("Expand", for: UIControlState())
508+
cell.selectionButton?.setTitle("Expand", for: UIControl.State())
509509
case .flat:
510-
cell.selectionButton?.setTitle("Flat", for: UIControlState())
510+
cell.selectionButton?.setTitle("Flat", for: UIControl.State())
511511
case .spiral:
512-
cell.selectionButton?.setTitle("Spiral", for: UIControlState())
512+
cell.selectionButton?.setTitle("Spiral", for: UIControl.State())
513513
case .fade:
514-
cell.selectionButton?.setTitle("Fade", for: UIControlState())
514+
cell.selectionButton?.setTitle("Fade", for: UIControl.State())
515515
case .dot:
516-
cell.selectionButton?.setTitle("Dot", for: UIControlState())
516+
cell.selectionButton?.setTitle("Dot", for: UIControl.State())
517517
}
518518
}
519519

M13Checkbox.xcodeproj/project.pbxproj

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,6 +572,7 @@
572572
ONLY_ACTIVE_ARCH = YES;
573573
SDKROOT = iphoneos;
574574
SWIFT_OPTIMIZATION_LEVEL = "-Onone";
575+
SWIFT_VERSION = 4.2;
575576
TARGETED_DEVICE_FAMILY = "1,2";
576577
};
577578
name = Debug;
@@ -618,6 +619,7 @@
618619
MTL_ENABLE_DEBUG_INFO = NO;
619620
SDKROOT = iphoneos;
620621
SWIFT_OPTIMIZATION_LEVEL = "-Owholemodule";
622+
SWIFT_VERSION = 4.2;
621623
TARGETED_DEVICE_FAMILY = "1,2";
622624
VALIDATE_PRODUCT = YES;
623625
};
@@ -634,7 +636,7 @@
634636
PRODUCT_BUNDLE_IDENTIFIER = com.brandonMcQuilkin.M13CheckboxDemo;
635637
PRODUCT_NAME = "$(TARGET_NAME)";
636638
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
637-
SWIFT_VERSION = 4.0;
639+
SWIFT_VERSION = 4.2;
638640
};
639641
name = Debug;
640642
};
@@ -649,7 +651,7 @@
649651
PRODUCT_BUNDLE_IDENTIFIER = com.brandonMcQuilkin.M13CheckboxDemo;
650652
PRODUCT_NAME = "$(TARGET_NAME)";
651653
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
652-
SWIFT_VERSION = 4.0;
654+
SWIFT_VERSION = 4.2;
653655
};
654656
name = Release;
655657
};
@@ -672,7 +674,7 @@
672674
PRODUCT_NAME = "$(TARGET_NAME)";
673675
SKIP_INSTALL = YES;
674676
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
675-
SWIFT_VERSION = 4.0;
677+
SWIFT_VERSION = 4.2;
676678
VERSIONING_SYSTEM = "apple-generic";
677679
VERSION_INFO_PREFIX = "";
678680
};
@@ -697,7 +699,7 @@
697699
PRODUCT_NAME = "$(TARGET_NAME)";
698700
SKIP_INSTALL = YES;
699701
SWIFT_SWIFT3_OBJC_INFERENCE = Default;
700-
SWIFT_VERSION = 4.0;
702+
SWIFT_VERSION = 4.2;
701703
VERSIONING_SYSTEM = "apple-generic";
702704
VERSION_INFO_PREFIX = "";
703705
};

Sources/M13CheckboxAnimationGenerator.swift

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,17 +35,17 @@ internal class M13CheckboxAnimationGenerator {
3535
if !reverse {
3636
animation.fromValue = 0.0
3737
animation.toValue = 1.0
38-
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseIn)
38+
animation.timingFunction = CAMediaTimingFunction(name: .easeIn)
3939
} else {
4040
animation.fromValue = 1.0
4141
animation.toValue = 0.0
4242
animation.beginTime = CACurrentMediaTime() + (animationDuration * 0.9)
43-
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut)
43+
animation.timingFunction = CAMediaTimingFunction(name: .easeOut)
4444
}
4545
// Set animation properties.
4646
animation.duration = animationDuration / 10.0
4747
animation.isRemovedOnCompletion = false
48-
animation.fillMode = kCAFillModeForwards
48+
animation.fillMode = CAMediaTimingFillMode.forwards
4949

5050
return animation
5151
}
@@ -94,8 +94,8 @@ internal class M13CheckboxAnimationGenerator {
9494
// Set animation properties.
9595
animation.duration = animationDuration
9696
animation.isRemovedOnCompletion = false
97-
animation.fillMode = kCAFillModeForwards
98-
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
97+
animation.fillMode = CAMediaTimingFillMode.forwards
98+
animation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
9999

100100
return animation
101101
}
@@ -131,8 +131,8 @@ internal class M13CheckboxAnimationGenerator {
131131
animation.toValue = toPath?.cgPath
132132
// Set animation properties.
133133
animation.duration = animationDuration
134-
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
135-
animation.fillMode = kCAFillModeForwards
134+
animation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
135+
animation.fillMode = CAMediaTimingFillMode.forwards
136136
animation.isRemovedOnCompletion = false
137137

138138
return animation
@@ -181,9 +181,9 @@ internal class M13CheckboxAnimationGenerator {
181181
animation.values = values.map({ NSValue(caTransform3D: $0) })
182182
animation.keyTimes = keyTimes.map({ NSNumber(value: $0 as Float) })
183183
animation.isRemovedOnCompletion = false
184-
animation.fillMode = kCAFillModeForwards
184+
animation.fillMode = CAMediaTimingFillMode.forwards
185185
animation.duration = animationDuration
186-
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseInEaseOut)
186+
animation.timingFunction = CAMediaTimingFunction(name: .easeInEaseOut)
187187

188188
return animation
189189
}

Sources/Managers/M13CheckboxBounceController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ internal class M13CheckboxBounceController: M13CheckboxController {
7979
]
8080

8181
// Setup the unselected box layer
82-
unselectedBoxLayer.lineCap = kCALineCapRound
82+
unselectedBoxLayer.lineCap = .round
8383
unselectedBoxLayer.rasterizationScale = UIScreen.main.scale
8484
unselectedBoxLayer.shouldRasterize = true
8585
unselectedBoxLayer.actions = newActions
@@ -90,7 +90,7 @@ internal class M13CheckboxBounceController: M13CheckboxController {
9090
unselectedBoxLayer.fillColor = nil
9191

9292
// Setup the selected box layer.
93-
selectedBoxLayer.lineCap = kCALineCapRound
93+
selectedBoxLayer.lineCap = .round
9494
selectedBoxLayer.rasterizationScale = UIScreen.main.scale
9595
selectedBoxLayer.shouldRasterize = true
9696
selectedBoxLayer.actions = newActions
@@ -99,8 +99,8 @@ internal class M13CheckboxBounceController: M13CheckboxController {
9999
selectedBoxLayer.transform = CATransform3DIdentity
100100

101101
// Setup the checkmark layer.
102-
markLayer.lineCap = kCALineCapRound
103-
markLayer.lineJoin = kCALineJoinRound
102+
markLayer.lineCap = .round
103+
markLayer.lineJoin = .round
104104
markLayer.rasterizationScale = UIScreen.main.scale
105105
markLayer.shouldRasterize = true
106106
markLayer.actions = newActions

Sources/Managers/M13CheckboxDotController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ internal class M13CheckboxDotController: M13CheckboxController {
7979
]
8080

8181
// Setup the unselected box layer
82-
unselectedBoxLayer.lineCap = kCALineCapRound
82+
unselectedBoxLayer.lineCap = .round
8383
unselectedBoxLayer.rasterizationScale = UIScreen.main.scale
8484
unselectedBoxLayer.shouldRasterize = true
8585
unselectedBoxLayer.actions = newActions
@@ -88,7 +88,7 @@ internal class M13CheckboxDotController: M13CheckboxController {
8888
unselectedBoxLayer.fillColor = nil
8989

9090
// Setup the selected box layer.
91-
selectedBoxLayer.lineCap = kCALineCapRound
91+
selectedBoxLayer.lineCap = .round
9292
selectedBoxLayer.rasterizationScale = UIScreen.main.scale
9393
selectedBoxLayer.shouldRasterize = true
9494
selectedBoxLayer.actions = newActions
@@ -97,8 +97,8 @@ internal class M13CheckboxDotController: M13CheckboxController {
9797
selectedBoxLayer.transform = CATransform3DIdentity
9898

9999
// Setup the checkmark layer.
100-
markLayer.lineCap = kCALineCapRound
101-
markLayer.lineJoin = kCALineJoinRound
100+
markLayer.lineCap = .round
101+
markLayer.lineJoin = .round
102102
markLayer.rasterizationScale = UIScreen.main.scale
103103
markLayer.shouldRasterize = true
104104
markLayer.actions = newActions

Sources/Managers/M13CheckboxExpandController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ internal class M13CheckboxExpandController: M13CheckboxController {
7979
]
8080

8181
// Setup the unselected box layer
82-
unselectedBoxLayer.lineCap = kCALineCapRound
82+
unselectedBoxLayer.lineCap = .round
8383
unselectedBoxLayer.rasterizationScale = UIScreen.main.scale
8484
unselectedBoxLayer.shouldRasterize = true
8585
unselectedBoxLayer.actions = newActions
@@ -88,7 +88,7 @@ internal class M13CheckboxExpandController: M13CheckboxController {
8888
unselectedBoxLayer.fillColor = nil
8989

9090
// Setup the selected box layer.
91-
selectedBoxLayer.lineCap = kCALineCapRound
91+
selectedBoxLayer.lineCap = .round
9292
selectedBoxLayer.rasterizationScale = UIScreen.main.scale
9393
selectedBoxLayer.shouldRasterize = true
9494
selectedBoxLayer.actions = newActions
@@ -97,8 +97,8 @@ internal class M13CheckboxExpandController: M13CheckboxController {
9797
selectedBoxLayer.transform = CATransform3DIdentity
9898

9999
// Setup the checkmark layer.
100-
markLayer.lineCap = kCALineCapRound
101-
markLayer.lineJoin = kCALineJoinRound
100+
markLayer.lineCap = .round
101+
markLayer.lineJoin = .round
102102
markLayer.rasterizationScale = UIScreen.main.scale
103103
markLayer.shouldRasterize = true
104104
markLayer.actions = newActions

Sources/Managers/M13CheckboxFadeController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ internal class M13CheckboxFadeController: M13CheckboxController {
7979
]
8080

8181
// Setup the unselected box layer
82-
unselectedBoxLayer.lineCap = kCALineCapRound
82+
unselectedBoxLayer.lineCap = .round
8383
unselectedBoxLayer.rasterizationScale = UIScreen.main.scale
8484
unselectedBoxLayer.shouldRasterize = true
8585
unselectedBoxLayer.actions = newActions
@@ -90,7 +90,7 @@ internal class M13CheckboxFadeController: M13CheckboxController {
9090
unselectedBoxLayer.fillColor = nil
9191

9292
// Setup the selected box layer.
93-
selectedBoxLayer.lineCap = kCALineCapRound
93+
selectedBoxLayer.lineCap = .round
9494
selectedBoxLayer.rasterizationScale = UIScreen.main.scale
9595
selectedBoxLayer.shouldRasterize = true
9696
selectedBoxLayer.actions = newActions
@@ -99,8 +99,8 @@ internal class M13CheckboxFadeController: M13CheckboxController {
9999
selectedBoxLayer.transform = CATransform3DIdentity
100100

101101
// Setup the checkmark layer.
102-
markLayer.lineCap = kCALineCapRound
103-
markLayer.lineJoin = kCALineJoinRound
102+
markLayer.lineCap = .round
103+
markLayer.lineJoin = .round
104104
markLayer.rasterizationScale = UIScreen.main.scale
105105
markLayer.shouldRasterize = true
106106
markLayer.actions = newActions

Sources/Managers/M13CheckboxFillController.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ internal class M13CheckboxFillController: M13CheckboxController {
5757
]
5858

5959
// Setup the unselected box layer
60-
unselectedBoxLayer.lineCap = kCALineCapRound
60+
unselectedBoxLayer.lineCap = .round
6161
unselectedBoxLayer.rasterizationScale = UIScreen.main.scale
6262
unselectedBoxLayer.shouldRasterize = true
6363
unselectedBoxLayer.actions = newActions
@@ -68,16 +68,16 @@ internal class M13CheckboxFillController: M13CheckboxController {
6868
unselectedBoxLayer.fillColor = nil
6969

7070
// Setup the selected box layer.
71-
selectedBoxLayer.lineCap = kCALineCapRound
71+
selectedBoxLayer.lineCap = .round
7272
selectedBoxLayer.rasterizationScale = UIScreen.main.scale
7373
selectedBoxLayer.shouldRasterize = true
7474
selectedBoxLayer.actions = newActions
7575

7676
selectedBoxLayer.transform = CATransform3DIdentity
7777

7878
// Setup the checkmark layer.
79-
markLayer.lineCap = kCALineCapRound
80-
markLayer.lineJoin = kCALineJoinRound
79+
markLayer.lineCap = .round
80+
markLayer.lineJoin = .round
8181
markLayer.rasterizationScale = UIScreen.main.scale
8282
markLayer.shouldRasterize = true
8383
markLayer.actions = newActions

0 commit comments

Comments
 (0)