Skip to content

Commit

Permalink
Merge pull request #56 from Marxon13/swift3
Browse files Browse the repository at this point in the history
Updated to Swift 3.
  • Loading branch information
Marxon13 committed Sep 11, 2016
2 parents c598d1b + 7d05d00 commit fa34386
Show file tree
Hide file tree
Showing 29 changed files with 927 additions and 956 deletions.
50 changes: 25 additions & 25 deletions M13Checkbox Demo/AnimationSelectionTableViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -9,90 +9,90 @@
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")
}

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)
}

}

@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)
}
}

Expand Down
12 changes: 6 additions & 6 deletions M13Checkbox Demo/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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:.
}

Expand Down
Loading

0 comments on commit fa34386

Please sign in to comment.