Created
June 17, 2016 22:31
-
-
Save jquave/380403b6ec270c89888b973d26f23269 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// fill with yellow | |
rectShape.fillColor = UIColor.yellowColor().CGColor | |
// 1 | |
// begin with a circle with a 50 points radius | |
let startShape = UIBezierPath(roundedRect: bounds, cornerRadius: 50).CGPath | |
// animation end with a large circle with 500 points radius | |
let endShape = UIBezierPath(roundedRect: CGRect(x: -450, y: -450, width: 1000, height: 1000), cornerRadius: 500).CGPath | |
// set initial shape | |
rectShape.path = startShape | |
// 2 | |
// animate the `path` | |
let animation = CABasicAnimation(keyPath: "path") | |
animation.toValue = endShape | |
animation.duration = 1 // duration is 1 sec | |
// 3 | |
animation.timingFunction = CAMediaTimingFunction(name: kCAMediaTimingFunctionEaseOut) // animation curve is Ease Out | |
animation.fillMode = kCAFillModeBoth // keep to value after finishing | |
animation.removedOnCompletion = false // don't remove after finishing | |
// 4 | |
rectShape.addAnimation(animation, forKey: animation.keyPath) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment