Latest 0.1.4
Homepage https://github.com/joshdhenry/SpinWheelControl
License BSD
Platforms ios 10.3
Frameworks UIKit
Authors

Spin Wheel Control v0.1.4

Synopsis

Spin Wheel Control is an inertial spinning wheel UI control that allows selection of an item. It is written in the Swift programming language can be used in iOS apps.

The code is a Swift derivation, port, and enhancement based loosely on the Objective-C "SMWheelControl" CocoaPod written by Cesare Rocchi and Simone Civetta found here.

Main languages and technologies used: Swift, UI Kit, Core Animation, CocoaPods, Interface Builder, Xcode

Installation

To run this on your own machine:

  • Install Cocoapods on your machine,

  • Create a podfile in the project’s root directory and add this line to that file within your target:
pod 'SpinWheelControl'
  • Run pod install from the command line while inside your project’s’ root directory.

No extra configuration should be necessary to include this control in Swift projects.

To make this work in your Objective-C project:

  • In your project’s (not the target’s) build settings, set the Defines Module flag to YES.

  • Find your product module name by going to your target’s (not the project’s) build setting and search for Project Module Name.

  • Add the SpinWheelControl files to your project.

  • Import in every Objective-C class you plan to use your Swift classes in. This file is automatically generated by the compiler when you include Swift classes in an Objective-C project.

Usage

Ensure the view controller containing the SpinWheelControl adheres to the SpinWheelControlDataSource and SpinWheelControlDelegate protocols:

class ViewController: UIViewController, SpinWheelControlDataSource, SpinWheelControlDelegate

Either instantiate the UIControl by dragging and dropping a SpinWheelControlView in Interface Builder and creating an IBOutlet, or instantiate the UI control with a frame via code like so:

let frame = CGRect(x: 0, y: 0, width: self.view.frame.size.width, height: self.view.frame.size.width)

spinWheelControl = SpinWheelControl(frame: frame)

Add a target for the valueChanged event:

spinWheelControl.addTarget(self, action: #selector(spinWheelDidChangeValue), for: UIControlEvents.valueChanged)

Give the SpinWheelControl a data source:

spinWheelControl.dataSource = self

spinWheelControl.reloadData()

Set the SpinWheelControl’s delegate:

spinWheelControl.delegate = self

Add the SpinWheelControl to your view:

self.view.addSubview(spinWheelControl)

Data Source Methods

The following data source methods are available:

//Specify the number of wedges in the spin wheel by returning a positive value that is greater than 1

func numberOfWedgesInSpinWheel(spinWheel: SpinWheelControl) -> UInt

//Returns the SpinWheelWedge at the specified index of the SpinWheelControl

func wedgeForSliceAtIndex(index: UInt) -> SpinWheelWedge

Delegate Methods

The following delegate methods are available:

//Triggered when the spin wheel control has come to rest after spinning.

func spinWheelDidEndDecelerating(spinWheel: SpinWheelControl)

//Triggered at various intervals. The variable radians describes how many radians the spin wheel control has moved since the last time this method was called.

func spinWheelDidRotateByRadians(radians: CGFloat)

Author

Josh Henry – Big Smash Software

Based loosely on the Objective-C "SMWheelControl" CocoaPod written by Cesare Rocchi and Simone Civetta found here.

License

BSD 3-Clause

Latest podspec

{
    "name": "SpinWheelControl",
    "version": "0.1.4",
    "summary": "An inertial spinning wheel UI control that allows selection of an item.",
    "description": "Spin Wheel Control is a wheel of fortune-style inertial spinning wheel UI control that allows selection of an item. It is written in the Swift programming language and to be used in iOS apps. The code is a Swift derivation, port, and enhancement based loosely on the Objective-C SMWheelControl CocoaPod written by Cesare Rocchi and Simone Civetta found at https://cocoapods.org/pods/SMWheelControl.",
    "homepage": "https://github.com/joshdhenry/SpinWheelControl",
    "license": {
        "type": "BSD",
        "file": "LICENSE.md"
    },
    "authors": {
        "Josh Henry": "[email protected]"
    },
    "source": {
        "git": "https://github.com/joshdhenry/SpinWheelControl.git",
        "tag": "0.1.4"
    },
    "frameworks": "UIKit",
    "platforms": {
        "ios": "10.3"
    },
    "source_files": "SpinWheelControl/*.{swift,h,m}",
    "pushed_with_swift_version": "3.0"
}

Pin It on Pinterest

Share This