Commit 7ad6d180 authored by toby's avatar toby

change barrier colors on shake

parent d8781b90
......@@ -31,6 +31,17 @@ extension UIView {
let timeSincePause = self.layer.convertTime(CACurrentMediaTime(), fromLayer: nil) - pausedTime
self.layer.beginTime = timeSincePause
}
func animateBackground(toColor: UIColor, duration: Double) {
UIView.animateWithDuration(
duration,
delay: 0.0,
options: UIViewAnimationOptions.CurveEaseOut | UIViewAnimationOptions.AllowUserInteraction,
animations: {
self.backgroundColor = toColor
},
completion: nil)
}
}
......
......@@ -98,7 +98,7 @@ class ViewController: UIViewController {
override func motionEnded(motion: UIEventSubtype, withEvent event: UIEvent) {
if motion == .MotionShake {
barriers.map({barrier in barrier.backgroundColor = randomColor()})
barriers.map({barrier in barrier.animateBackground(randomColor(), duration: 0.2)})
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment