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.
-
Called when spin button tapped
Declaration
Swift
public var onSpinButtonTap: (() -> Void)?
-
Callback for edge collision
Declaration
Swift
public var onEdgeCollision: ((_ progress: Double?) -> Void)?
-
Callback for center collision
Declaration
Swift
public var onCenterCollision: ((_ progress: Double?) -> Void)?
-
Callback for
wheelView
tap, returns selected indexDeclaration
Swift
public var onWheelTap: ((_ index: Int) -> Void)?
-
Turns on tap gesture recognizer for
wheelView
Declaration
Swift
public var wheelTapGestureOn: Bool { get set }
-
Declaration
Swift
public var impactFeedbackOn: Bool { get set }
-
Declaration
Swift
public var edgeCollisionDetectionOn: Bool
-
Declaration
Swift
public var centerCollisionDetectionOn: Bool
-
Declaration
Swift
public var edgeCollisionSound: AudioFile? { get set }
-
Declaration
Swift
public var centerCollisionSound: AudioFile? { get set }
-
PinImageView
collision effect configuratorDeclaration
Swift
public var pinImageViewCollisionEffect: CollisionEffect?
-
Customizable configuration. Required in order to draw properly.
Declaration
Swift
public var configuration: SFWConfiguration? { get set }
-
List of Slice objects. Used to draw content.
Declaration
Swift
open var slices: [Slice] { get set }
-
Audio player manager, used for collision effects sound
Declaration
Swift
private(set) lazy var audioPlayerManager: AudioPlayerManager { get set }
-
Undocumented
Declaration
Swift
private(set) lazy var impactFeedbackgenerator: UIImpactFeedbackGenerator { get set }
-
Initiates without IB.
Declaration
Swift
public init(frame: CGRect, slices: [Slice], configuration: SFWConfiguration?)
Parameters
frame
Frame
slices
List of Slices
configuration
Customizable configuration
-
Undocumented
Declaration
Swift
public required init?(coder aDecoder: NSCoder)
-
-
-
-
Undocumented
Declaration
Swift
override public func layoutSubviews()
-
-
/ Animation conformance
Declaration
Swift
var layerToAnimate: SpinningAnimatable? { get }
-
Declaration
Swift
var sliceDegree: CGFloat? { get }
-
Declaration
Swift
var edgeAnchorRotationOffset: CGFloat { get }
-
Declaration
Swift
var centerAnchorRotationOffset: CGFloat { get }
-
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
-
startRotationAnimation(finishIndex:
continuousRotationTime: continuousRotationSpeed: rotationOffset: _: ) 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
-
Pin image name from assets catalog, sets image to the
pinImageView
Declaration
Swift
@IBInspectable var pinImage: String? { get set }
-
is
pinImageView
hiddenDeclaration
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
hiddenDeclaration
Swift
@IBInspectable var isSpinHidden: Bool { get set }
-
Is
spinButton
enabledDeclaration
Swift
@IBInspectable var isSpinEnabled: Bool { get set }
-
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