Hi all,
I'm making an app that I have to have a flip animation when someone taps a button.
Here's the code:
import WatchKit
import Foundation
class InterfaceController: WKInterfaceController {
@IBOutlet var coin: WKInterfaceImage!
@IBOutlet var txt: WKInterfaceLabel!
override func awake(withContext context: Any?) {
super.awake(withContext: context)
txt.setText("Heads or Tails?")
}
@IBAction func CallIt()
{
let array = ["Heads","Tails"]
let randomIndex = Int(arc4random_uniform(UInt32(array.count)))
if randomIndex == 1
{
let up = UIImage(named: "Heads")
coin.setImage(up)
txt.setText("Heads")
}else {
let down = UIImage(named: "Tails")
coin.setImage(down)
txt.setText("Tails")
}
}
}
Thanks in advance,
Dan Uff