Skip to content

Instantly share code, notes, and snippets.

@petrosDemetrakopoulos
Created February 15, 2021 09:06
Show Gist options
  • Select an option

  • Save petrosDemetrakopoulos/4eafe07c0d1680db2b596b460577971c to your computer and use it in GitHub Desktop.

Select an option

Save petrosDemetrakopoulos/4eafe07c0d1680db2b596b460577971c to your computer and use it in GitHub Desktop.
Roulett UI
var body: some View {
VStack {
Text(self.isAnimating ? "Spining\n..." : sectorFromAngle(angle : newAngle))
.multilineTextAlignment(.center)
Image("Arrow")
.resizable()
.scaledToFit()
.frame(width: 25, height: 25, alignment: .center)
Image("roulette")
.resizable()
.scaledToFit()
.rotationEffect(Angle(degrees: spinDegrees))
.frame(width: 245, height: 245, alignment: .center)
.animation(spinAnimation)
Button("SPIN") {
isAnimating = true
rand = Double.random(in: 1...360)
spinDegrees += 720.0 + rand
newAngle = getAngle(angle: spinDegrees)
DispatchQueue.main.asyncAfter(deadline: .now() + 2.9) {
isAnimating = false
}
}
.padding(40)
.disabled(isAnimating == true)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment