Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @IBOutlet var labelMiles: UILabel!
- let animationDuration = 1.5
- let animationStartDate = Date()
- @IBAction func accelerateButton(_ sender: UIButton) {
- // CAD display here; para animacion de MILES
- let cadDisplay = CADisplayLink(target: self, selector: #selector(accelerateButton(_:)))
- cadDisplay.add(to: .main, forMode: RunLoop.Mode.default)
- guard let startValue = self.myCar.miles else { return () }
- // myCar.addMiles(addToMiles: 10.0)
- let endValue = self.myCar.miles! + 10
- let now = Date()
- let elapsedTime = now.timeIntervalSince(animationStartDate)
- if elapsedTime > animationDuration {
- self.labelMiles.text = "(endValue)"
- } else {
- let percentage = elapsedTime / animationDuration
- let value = percentage * (endValue - startValue)
- self.labelMiles.text = "(value)"
- }
- /*myCar.acceletate()
- updateView()*/
- }
- myCar = Car(miles: 12000.50, tires: 4, model: "SUV Santa Fe", age: 2019, companyName: "Hyundai", color: #colorLiteral(red: 0.05882352963, green: 0.180392161, blue: 0.2470588237, alpha: 1), imageName: UIImage(named: "Hyundai.jpg"))
- myGarage.append(myCar)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement