Closed oenama closed 4 years ago
like in here I wanna get/print the prize ($200) on startAnimating - > finished
@sh-khashimov
when you start rotation animation, you specify the finish index. Please, read the API overview.
when you start rotation animation, you specify the finish index. Please, read the API overview.
I did, but how can I add the finished index at pin image position? or like if I wanted it to be random and still need to get the prize title at pin image position
@sh-khashimov from VariousWheelSimpleViewController.swift
var finishIndex: Int {
return Int.random(in: 0..<wheelControl.slices.count)
}
wheelControl.startAnimating(indefiniteRotationTimeInSeconds: 1, finishIndex: finishIndex) { (finished) in
print(finished)
if finished {
print(self.finishIndex)
/// --> here
print(self.prizes[self.finishIndex])
}
}
Regardless of your pin position, if configuration.wheelPreferences.startPosition
set to .top
, your rotation animation will stop at specified finishIndex
.
if configuration.wheelPreferences.startPosition
set to .top
and your pin also on the top position, rotation always stops at the top. (at the pin position)
code from VariousWheelSimpleViewController.swift
won't work for you. self.finishIndex
is a computed property, when you call print(self.finishIndex)
, it will return a new random number.
try this:
let _finishIndex = self.finishIndex
wheelControl.startAnimating(indefiniteRotationTimeInSeconds: 1, finishIndex: _finishIndex) { (finished) in
print(finished)
if finished {
print(_finishIndex)
/// --> here
print(self.prizes[_finishIndex])
}
}
Regardless of your pin position, if
configuration.wheelPreferences.startPosition
set to.top
, your rotation animation will stop at specifiedfinishIndex
. ifconfiguration.wheelPreferences.startPosition
set to.top
and your pin also on the top position, rotation always stops at the top. (at the pin position)code from
VariousWheelSimpleViewController.swift
won't work for you.self.finishIndex
is a computed property, when you callprint(self.finishIndex)
, it will return a new random number.
I completely missed that, Thank you for your help
How can we get the finished index to be at pin image if it was on top?
any idea? @sh-khashimov