SwiftFortuneWheel

public class SwiftFortuneWheel : SFWControl
extension SwiftFortuneWheel: SliceCalculating
extension SwiftFortuneWheel: ImpactFeedbackable
extension SwiftFortuneWheel: AudioPlayable
extension SwiftFortuneWheel: SpinningAnimatorProtocol

Customizable Fortune spinning wheel control written in Swift.

SpinningAnimatorProtocol

Public API (Animation)

  • Rotates to the specified index

    Declaration

    Swift

    func rotate(toIndex index: Int, animationDuration: CFTimeInterval = 0.00001)

    Parameters

    index

    Index

    animationDuration

    Animation duration

  • Rotates to the specified angle offset

    Declaration

    Swift

    func rotate(rotationOffset: CGFloat, animationDuration: CFTimeInterval = 0.00001)

    Parameters

    rotationOffset

    Rotation offset

    animationDuration

    Animation duration

  • Starts rotation animation and stops rotation at the specified rotation offset angle

    Declaration

    Swift

    func startRotationAnimation(rotationOffset: CGFloat, fullRotationsCount: Int = 13, animationDuration: CFTimeInterval = 5.000, _ completion: ((Bool) -> Void)?)

    Parameters

    rotationOffset

    Rotation offset

    fullRotationsCount

    Full rotations until start deceleration

    animationDuration

    Animation duration

    completion

    Completion handler

  • Starts rotation animation and stops rotation at the specified index

    Declaration

    Swift

    func startRotationAnimation(finishIndex: Int, fullRotationsCount: Int = 13, animationDuration: CFTimeInterval = 5.000, _ completion: ((Bool) -> Void)?)

    Parameters

    finishIndex

    Finish at index

    fullRotationsUntilFinish

    Full rotations until start deceleration

    animationDuration

    Animation duration

    completion

    Completion handler

  • Starts indefinite rotation and stops rotation at the specified index

    Declaration

    Swift

    func startRotationAnimation(finishIndex: Int, continuousRotationTime: Int, continuousRotationSpeed: CGFloat = 4, _ completion: ((Bool) -> Void)?)

    Parameters

    finishIndex

    Finish at index

    continuousRotationTime

    Full rotation time in seconds before stops

    continuousRotationSpeed

    Rotation speed

    completion

    Completion handler

  • Starts indefinite rotation and stops rotation at the specified index

    Declaration

    Swift

    func startRotationAnimation(finishIndex: Int, continuousRotationTime: Int, continuousRotationSpeed: CGFloat = 4, rotationOffset: CGFloat = 0, _ completion: ((Bool) -> Void)?)

    Parameters

    finishIndex

    Finish at index

    continuousRotationTime

    Full rotation time in seconds before stops

    continuousRotationSpeed

    Rotation speed

    rotationOffset

    Rotation offset

    completion

    Completion handler

  • Starts continuos rotation animation

    Declaration

    Swift

    func startContinuousRotationAnimation(with speed: CGFloat = 4)

    Parameters

    speed

    Rotation speed

  • Stops rotation animation

    Declaration

    Swift

    func stopRotation()
  • Starts rotation animation and stops rotation at the specified index and rotation angle offset

    Declaration

    Swift

    func startRotationAnimation(finishIndex: Int, rotationOffset: CGFloat, fullRotationsCount: Int = 13, animationDuration: CFTimeInterval = 5.000, _ completion: ((Bool) -> Void)?)

    Parameters

    finishIndex

    finished at index

    rotationOffset

    Rotation offset

    fullRotationsUntilFinish

    Full rotations until start deceleration

    animationDuration

    Animation duration

    completion

    completion

Public API (IBInspectable)

  • Pin image name from assets catalog, sets image to the pinImageView

    Declaration

    Swift

    @IBInspectable
    var pinImage: String? { get set }
  • is pinImageView hidden

    Declaration

    Swift

    @IBInspectable
    var isPinHidden: Bool { get set }
  • Spin button image name from assets catalog, sets image to the spinButton

    Declaration

    Swift

    @IBInspectable
    var spinImage: String? { get set }
  • Spin button background image from assets catalog, sets background image to the spinButton

    Declaration

    Swift

    @IBInspectable
    var spinBackgroundImage: String? { get set }
  • Spin button title text, sets title text to the spinButton

    Declaration

    Swift

    @IBInspectable
    var spinTitle: String? { get set }
  • Is spinButton hidden

    Declaration

    Swift

    @IBInspectable
    var isSpinHidden: Bool { get set }
  • Is spinButton enabled

    Declaration

    Swift

    @IBInspectable
    var isSpinEnabled: Bool { get set }

Deprecated API

  • Starts indefinite rotation animation

    Declaration

    Swift

    @available(*, deprecated, message: "Use startContinuousRotationAnimation(with: speed﹚ instead")
    func startAnimating(rotationTime: CFTimeInterval = 5.000, fullRotationCountInRotationTime: CGFloat = 7000)

    Parameters

    rotationTime

    Rotation time is how many seconds needs to rotate all full rotation counts, default value is 5.000

    fullRotationCountInRotationTime

    How many rotation should be done for spefied rotation time, default value is 7000

  • Stops all animations

    Declaration

    Swift

    @available(*, deprecated, renamed: "stopRotation")
    func stopAnimating()
  • Starts indefinite rotation and stops rotation at the specified index

    Declaration

    Swift

    @available(*, deprecated, message: "Use startRotationAnimation(finishIndex:continuousRotationTime:completion:﹚ instead")
    func startAnimating(indefiniteRotationTimeInSeconds: Int, finishIndex: Int, _ completion: ((Bool) -> Void)?)

    Parameters

    indefiniteRotationTimeInSeconds

    full rotation time in seconds before stops

    finishIndex

    finished at index

    completion

    completion

  • Starts rotation animation and stops rotation at the specified index and rotation angle offset

    Declaration

    Swift

    @available(*, deprecated, renamed: "startRotationAnimation(finishIndex:rotationOffset:fullRotationsCount:animationDuration:completion:﹚")
    func startAnimating(finishIndex: Int, rotationOffset: CGFloat, fullRotationsUntilFinish: Int = 13, animationDuration: CFTimeInterval = 5.000, _ completion: ((Bool) -> Void)?)

    Parameters

    finishIndex

    finished at index

    rotationOffset

    Rotation offset

    fullRotationsUntilFinish

    Full rotations until start deceleration

    animationDuration

    Animation duration

    completion

    completion

  • Starts rotation animation and stops rotation at the specified rotation offset angle

    Declaration

    Swift

    @available(*, deprecated, renamed: "startRotationAnimation(rotationOffset:fullRotationsCount:animationDuration:completion:﹚")
    func startAnimating(rotationOffset: CGFloat, fullRotationsUntilFinish: Int = 13, animationDuration: CFTimeInterval = 5.000, _ completion: ((Bool) -> Void)?)

    Parameters

    rotationOffset

    Rotation offset

    fullRotationsUntilFinish

    Full rotations until start deceleration

    animationDuration

    Animation duration

    completion

    Completion handler

  • Starts rotation animation and stops rotation at the specified index

    Declaration

    Swift

    @available(*, deprecated, renamed: "startRotationAnimation(finishIndex:fullRotationsCount:animationDuration:completion:﹚")
    func startAnimating(finishIndex: Int, fullRotationsUntilFinish: Int = 13, animationDuration: CFTimeInterval = 5.000, _ completion: ((Bool) -> Void)?)

    Parameters

    finishIndex

    Finish at index

    fullRotationsUntilFinish

    Full rotations until start deceleration

    animationDuration

    Animation duration

    completion

    Completion handler