/ Lucky wheel

An iOS Lucky wheel with customizable text and text colors

An iOS Lucky wheel with customizable text and text colors

iOSLuckyWheel

An iOS Lucky wheel with customizable text and text colors and section colors and very easy to integrate.

iOSLuckyWheel

Example

To run the example project, clone the repo, and run pod install from the Example directory first.

Requirements

Installation

iOSLuckyWheel is available through CocoaPods. To install
it, simply add the following line to your Podfile:

pod 'iOSLuckyWheel'

Usage

Create the view extending LuckWheel by frame

import iOSLuckyWheel
class ViewController: UIViewController,LuckyWheelDataSource,LuckyWheelDelegate {
    var wheel :LuckyWheel?
    override func viewDidLoad() {
        super.viewDidLoad()
        wheel = LuckyWheel(frame: CGRect(x: 0, y: 0, width: view.frame.width - 40 , height: 300))
        wheel?.delegate = self
        wheel?.dataSource = self
        wheel?.center = self.view.center
        wheel?.setTarget(section: 5)
        wheel?.animateLanding = true
        self.view.addSubview(wheel!)
    }
    func numberOfSections() -> Int {
        return 8
    }
    func itemsForSections() -> [WheelItem] {
        let item = WheelItem(title: "Welcome to iOS Lucky Wheel", titleColor: UIColor.white, itemColor: UIColor.blue)
        return [item,item,item,item,item,item,item,item]
    }
    func wheelDidChangeValue(_ newValue: Int) {
        print(newValue)
    }
    
}

Data Source

func numberOfSections() ->Int // number of wheel sections
func itemsForSections() -> [WheelItem] // the items to be displayed

Delegate

func wheelDidChangeValue(_ newValue: Int) // the selected section  postion
@objc optional func lastAnimation() ->CABasicAnimation // custom animation after landing 
@objc optional func landingPostion() ->LandingPostion  // the landing postion [top,bottom,left,right]

the landing position is the direction where the wheel stops after selecting a section

properties

public func setTarget(section:Int) // set landing target 
public var infinteRotation = false // to rotate infinitely 
public var animateLanding = false // to whether animate after landing or not. 
public func manualRotation(aCircleTime: Double) // manual rotation with time 
public func stop() // manual Stop

GitHub