From 7d05d00dfcfc15ae5fb1cd5846a68a6a65e182b4 Mon Sep 17 00:00:00 2001 From: Brandon McQuilkin Date: Sun, 11 Sep 2016 11:18:28 -0400 Subject: [PATCH] Updated to Swift 3. --- ...nimationSelectionTableViewController.swift | 50 +-- M13Checkbox Demo/AppDelegate.swift | 12 +- M13Checkbox Demo/Base.lproj/Main.storyboard | 186 ++++------ M13Checkbox Demo/CollectionViewLayout.swift | 42 +-- .../ColorCollectionViewCell.swift | 14 +- M13Checkbox Demo/DemoViewController.swift | 340 +++++++++--------- .../SegmentedControlCollectionViewCell.swift | 2 +- .../SelectionCollectionViewCell.swift | 4 +- .../SliderCollectionViewCell.swift | 2 +- M13Checkbox.podspec | 4 +- M13Checkbox.xcodeproj/project.pbxproj | 15 +- .../xcschemes/M13Checkbox.xcscheme | 2 +- Readme.md | 15 +- Sources/M13Checkbox+IB.swift | 8 +- Sources/M13Checkbox.swift | 198 +++++----- Sources/M13CheckboxAnimationPresets.swift | 36 +- Sources/M13CheckboxGestureRecognizer.swift | 12 +- Sources/M13CheckboxManager.swift | 12 +- Sources/M13CheckboxPathPresets.swift | 103 +++--- .../Managers/M13CheckboxBounceManager.swift | 104 +++--- Sources/Managers/M13CheckboxDotManager.swift | 108 +++--- .../Managers/M13CheckboxExpandManager.swift | 104 +++--- Sources/Managers/M13CheckboxFadeManager.swift | 100 +++--- Sources/Managers/M13CheckboxFillManager.swift | 82 ++--- Sources/Managers/M13CheckboxFlatManager.swift | 118 +++--- .../Managers/M13CheckboxSpiralManager.swift | 96 ++--- .../Managers/M13CheckboxStrokeManager.swift | 86 ++--- .../Presets/M13CheckboxDotPathPresets.swift | 4 +- .../M13CheckboxSpiralPathPresets.swift | 24 +- 29 files changed, 927 insertions(+), 956 deletions(-) diff --git a/M13Checkbox Demo/AnimationSelectionTableViewController.swift b/M13Checkbox Demo/AnimationSelectionTableViewController.swift index 06509e2..ba75eff 100644 --- a/M13Checkbox Demo/AnimationSelectionTableViewController.swift +++ b/M13Checkbox Demo/AnimationSelectionTableViewController.swift @@ -9,61 +9,61 @@ import UIKit protocol AnimationSelectionTableViewControllerDelegate { - func selectedAnimation(animation: M13Checkbox.Animation) + func selectedAnimation(_ animation: M13Checkbox.Animation) } class AnimationSelectionTableViewController: UITableViewController { - let animations: [M13Checkbox.Animation] = [.Stroke, .Fill, .Bounce(.Stroke), .Expand(.Stroke), .Flat(.Stroke), .Spiral, .Fade(.Stroke), .Dot(.Stroke)] + let animations: [M13Checkbox.Animation] = [.stroke, .fill, .bounce(.stroke), .expand(.stroke), .flat(.stroke), .spiral, .fade(.stroke), .dot(.stroke)] var delegate: AnimationSelectionTableViewControllerDelegate? override func viewDidLoad() { super.viewDidLoad() - tableView.backgroundColor = UIColor.clearColor() - tableView.backgroundView?.backgroundColor = UIColor.clearColor() + tableView.backgroundColor = UIColor.clear + tableView.backgroundView?.backgroundColor = UIColor.clear } // MARK: - Table view data source - override func numberOfSectionsInTableView(tableView: UITableView) -> Int { + override func numberOfSections(in tableView: UITableView) -> Int { return 1 } - override func tableView(tableView: UITableView, numberOfRowsInSection section: Int) -> Int { + override func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int { // #warning Incomplete implementation, return the number of rows return animations.count } - override func tableView(tableView: UITableView, cellForRowAtIndexPath indexPath: NSIndexPath) -> UITableViewCell { - let cell = tableView.dequeueReusableCellWithIdentifier("animationCell", forIndexPath: indexPath) + override func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell { + let cell = tableView.dequeueReusableCell(withIdentifier: "animationCell", for: indexPath) - let animation = animations[indexPath.row] + let animation = animations[(indexPath as NSIndexPath).row] switch animation { - case .Stroke: + case .stroke: cell.textLabel?.text = "Stroke" cell.imageView?.image = UIImage(named: "Stroke") - case .Fill: + case .fill: cell.textLabel?.text = "Fill" cell.imageView?.image = UIImage(named: "Fill") - case .Bounce: + case .bounce: cell.textLabel?.text = "Bounce" cell.imageView?.image = UIImage(named: "Bounce") - case .Expand: + case .expand: cell.textLabel?.text = "Expand" cell.imageView?.image = UIImage(named: "Expand") - case .Flat: + case .flat: cell.textLabel?.text = "Flat" cell.imageView?.image = UIImage(named: "Flat") - case .Spiral: + case .spiral: cell.textLabel?.text = "Spiral" cell.imageView?.image = UIImage(named: "Spiral") - case .Fade: + case .fade: cell.textLabel?.text = "Fade" cell.imageView?.image = UIImage(named: "Fade") - case .Dot: + case .dot: cell.textLabel?.text = "Dot" cell.imageView?.image = UIImage(named: "Dot") } @@ -71,14 +71,14 @@ class AnimationSelectionTableViewController: UITableViewController { return cell } - override func tableView(tableView: UITableView, willDisplayCell cell: UITableViewCell, forRowAtIndexPath indexPath: NSIndexPath) { - cell.backgroundColor = UIColor.clearColor() - cell.contentView.backgroundColor = UIColor.clearColor() + override func tableView(_ tableView: UITableView, willDisplay cell: UITableViewCell, forRowAt indexPath: IndexPath) { + cell.backgroundColor = UIColor.clear + cell.contentView.backgroundColor = UIColor.clear } - override func tableView(tableView: UITableView, didSelectRowAtIndexPath indexPath: NSIndexPath) { - delegate?.selectedAnimation(animations[indexPath.row]) - presentingViewController?.dismissViewControllerAnimated(true, completion: nil) + override func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) { + delegate?.selectedAnimation(animations[(indexPath as NSIndexPath).row]) + presentingViewController?.dismiss(animated: true, completion: nil) } } @@ -86,13 +86,13 @@ class AnimationSelectionTableViewController: UITableViewController { @IBDesignable class AnimationCell: UITableViewCell { - @IBInspectable var imageSize: CGSize = CGSizeZero + @IBInspectable var imageSize: CGSize = CGSize.zero override func layoutSubviews() { super.layoutSubviews() if let imageView = imageView { - imageView.frame = CGRectMake(imageView.frame.origin.x, (frame.size.height - imageSize.height) / 2.0, imageSize.width, imageSize.height) + imageView.frame = CGRect(x: imageView.frame.origin.x, y: (frame.size.height - imageSize.height) / 2.0, width: imageSize.width, height: imageSize.height) } } diff --git a/M13Checkbox Demo/AppDelegate.swift b/M13Checkbox Demo/AppDelegate.swift index 2a693fa..4e8cbfc 100644 --- a/M13Checkbox Demo/AppDelegate.swift +++ b/M13Checkbox Demo/AppDelegate.swift @@ -16,29 +16,29 @@ class AppDelegate: UIResponder, UIApplicationDelegate { var window: UIWindow? - func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool { + func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool { return true } - func applicationWillResignActive(application: UIApplication) { + func applicationWillResignActive(_ application: UIApplication) { // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state. // Use this method to pause ongoing tasks, disable timers, and throttle down OpenGL ES frame rates. Games should use this method to pause the game. } - func applicationDidEnterBackground(application: UIApplication) { + func applicationDidEnterBackground(_ application: UIApplication) { // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later. // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits. } - func applicationWillEnterForeground(application: UIApplication) { + func applicationWillEnterForeground(_ application: UIApplication) { // Called as part of the transition from the background to the inactive state; here you can undo many of the changes made on entering the background. } - func applicationDidBecomeActive(application: UIApplication) { + func applicationDidBecomeActive(_ application: UIApplication) { // Restart any tasks that were paused (or not yet started) while the application was inactive. If the application was previously in the background, optionally refresh the user interface. } - func applicationWillTerminate(application: UIApplication) { + func applicationWillTerminate(_ application: UIApplication) { // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:. } diff --git a/M13Checkbox Demo/Base.lproj/Main.storyboard b/M13Checkbox Demo/Base.lproj/Main.storyboard index 8b5d647..24d9968 100644 --- a/M13Checkbox Demo/Base.lproj/Main.storyboard +++ b/M13Checkbox Demo/Base.lproj/Main.storyboard @@ -1,20 +1,11 @@ - - + + - + + - - - - - - - - - - @@ -27,8 +18,30 @@ + + + + + + + + + + + + + + + + + + + + + + + - @@ -50,32 +63,8 @@ - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -137,7 +126,7 @@ - + @@ -152,16 +141,14 @@ - - + - - + @@ -172,8 +159,7 @@ - - + @@ -223,33 +209,33 @@ - - + + - + - + - + - + - + @@ -268,7 +254,7 @@ - + @@ -277,7 +263,7 @@ - + @@ -293,35 +279,30 @@ - - + - - + - + - - @@ -361,33 +342,28 @@ - - @@ -423,36 +399,31 @@ - - + - - @@ -487,23 +458,20 @@ -